我的目标是,在每个活动开始时,检查主Facebook应用程序中的Facebook帐户是否已更改,如果更改了强制继续
LoginManager.getInstance().logOut();
这里s my login code (i
我没有使用会话):
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
try {
SharedPreferences set = getSharedPreferences("account_pref", 0);
SharedPreferences.Editor editor = set.edit();
editor.putString("fb_logged", "true");
editor.putString("fb_user", object.getString("name"));
editor.commit();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name");
request.setParameters(parameters);
request.executeAsync();
}