我尝试使用accessToken从Graph API获取更新数据,但它始终显示Logout按钮屏幕。
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
accessToken = newAccessToken;
}
};
@Override
protected void onDestroy() {
super.onDestroy();
if(isFromFb){
accessTokenTracker.stopTracking();
}
}
if(accessToken != null) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.d("TestLog user : " , object.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday,picture.type(large),friends");
request.setParameters(parameters);
request.executeAsync();
}
如何在Facebook SDK 4.0中第二次获取最新的个人资料数据
答案 0 :(得分:0)
尝试此操作您可以在每次获取用户详细信息后以编程方式注销用户,例如LoginManager.getInstance().logOut();
有关详情,请参阅此处: - http://coderzpassion.com/android-using-facebook-login-application-using-latest-facebook-sdk/
答案 1 :(得分:0)
抱歉,我在最后得到了一个小错误,我得到了答案。我需要先获取当前的accessToken。但是早些时候我才采取onCurrentAccessTokenChanged方法。
accessToken = AccessToken.getCurrentAccessToken();
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
accessToken = newAccessToken;
}
};
@Override
protected void onDestroy() {
super.onDestroy();
if(isFromFb){
accessTokenTracker.stopTracking();
}
}
if(accessToken != null) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.d("TestLog user : " , object.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday,picture.type(large),friends");
request.setParameters(parameters);
request.executeAsync();
}