use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class UserSettingsFragment method fetchUserInfo.
private void fetchUserInfo() {
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken != null) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject me, GraphResponse response) {
user = me;
updateUI();
}
});
Bundle parameters = new Bundle();
parameters.putString(FIELDS, REQUEST_FIELDS);
request.setParameters(parameters);
GraphRequest.executeBatchAsync(request);
} else {
user = null;
}
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class UserSettingsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
fetchUserInfo();
updateUI();
}
};
callbackManager = CallbackManager.Factory.create();
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class ProfileFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
callbackManager = CallbackManager.Factory.create();
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
setProfile(currentProfile);
}
};
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
// On AccessToken changes fetch the new profile which fires the event on
// the ProfileTracker if the profile is different
Profile.fetchProfileForCurrentAccessToken();
}
};
// Ensure that our profile is up to date
Profile.fetchProfileForCurrentAccessToken();
setProfile(Profile.getCurrentProfile());
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class SettingsFragment method currentUserChanged.
private void currentUserChanged() {
if (slotManager == null) {
// Fragment has not had onCreate called yet.
return;
}
updateMenuVisibility();
updateListView();
Slot currentSlot = slotManager.getSelectedSlot();
AccessToken currentToken = (currentSlot != null) ? currentSlot.getAccessToken() : null;
AccessToken.setCurrentAccessToken(currentToken);
}
Aggregations