我想在注销Facebook时清理userinfo textview。但我不知道我实际登出的是哪一部分。并且不知道我在哪里清理信息(名字,姓氏)任何想法?提前谢谢。
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();
}
答案 0 :(得分:0)
由于您没有在sharedPref或数据库中存储名字或姓氏,因此无需清除任何数据,只需设置textview:
userinfo.setText("");