0
當用戶通過Facebook撤消應用權限時,此代碼應該要求用戶重新授權,但不是。任何人都可以看到錯誤? 「臉譜」是一個Facebook對象。Android:Facebook用戶撤銷權限,不會授權
public void facebookSetup() {
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null); //load an access token from sharedPreferences
long expires = mPrefs.getLong("access_expires", 0); //do the same for the token expiration time
if (access_token != null) { //if the access token exists in sharedPreferences, we'll use it
facebook.setAccessToken(access_token);
}
if (expires != 0) { //if the expiration time exists in shared preferences, use it
facebook.setAccessExpires(expires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(this, new String[] { "email", "publish_stream", "user_photos", "publish_actions"}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
}