我想在清理Facebook時清理我的userinfo textview。但我不知道我實際註銷了哪一部分。並不知道我需要清理信息(名字,姓氏)有什麼想法?提前致謝。清理信息Facebook登出
MainActivity.java
public class LoginActivity extends AppCompatActivity {
private TextView userinfo;
private CallbackManager callbackManager;
private LoginButton loginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
FacebookSdk.sdkInitialize(getApplicationContext());
LoginManager.getInstance().logOut();
setContentView(R.layout.activity_login);
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton)findViewById(R.id.login_button);
userinfo= (TextView) findViewById(R.id.textView);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult)
{
Toast.makeText(LoginActivity.this,"Oturum başarı ile açıldı!",Toast.LENGTH_LONG).show();
setFacebookData(loginResult);
}
@Override
public void onCancel() {
Toast.makeText(LoginActivity.this,"Giriş işlemi iptal edildi.",Toast.LENGTH_LONG).show();
}
@Override
public void onError(FacebookException error) {
Toast.makeText(LoginActivity.this,"Giriş başarısız.",Toast.LENGTH_LONG).show();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
}
private void setFacebookData(final LoginResult loginResult)
{
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response)
{
try {
String firstName = response.getJSONObject().getString("first_name");
String lastName = response.getJSONObject().getString("last_name");
Log.i("Login"+ "FirstName", firstName);
Log.i("Login" + "LastName", lastName);
userinfo.setText("Hoşgeldiniz, "+firstName + " " +lastName+"!");
}
catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "first_name,last_name");
request.setParameters(parameters);
request.executeAsync();
}
我可以在registercallback函數結束時使用settext嗎? –