my problem is that I hav an app which can connects to facebook using facebook sdk new version(4.0) and I want that when the user logs into facebook , a textview appears and show it's name and when log out clicked the textview disappears.
the first part is done and I can get the data I want:
btnLoginButton.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
fBLogInClicked = true;
GraphRequest.newMeRequest(loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object,
GraphResponse response) {
try {
String jsonresult = String
.valueOf(object);
String str_firstname = object .getString("first_name");
String str_lastname = object
.getString("last_name");
fullName = str_firstname + " "
+ str_lastname;
} catch (JSONException e) {
e.printStackTrace();
}
if (fullName != null) {
txtFBEmail
.setVisibility(View.VISIBLE);
txtFBEmail.setText(fullName);
}
}
}
}).executeAsync();
}
but after logout I don't know how to understand that logout is clicked and then to set visibility of txtFBEmail gone.
I tryed this code on onCreate() but just when I restart the app is partly useful and when log out clicks I can not give the order to disappear the textview.:
AccessToken fb_token = AccessToken.getCurrentAccessToken();
if(fb_token == null) {
txtFBEmail.setVisibility(View.GONE);
}