我注意到有些游戏使用 Facebook SDK 登录他们的游戏。我第一次登录时,它会显示一个登录表单并转到他们的应用程序。注销并再次登录后,它不再显示 Facebook 登录表单。如果我想用另一个 Facebook 帐户登录,我必须使用 Facebook 应用程序。为什么?为什么游戏的注销按钮也无法注销Facebook?这是一个正确的机制吗?
问问题
303 次
2 回答
2
打开由 facebook sdk 提供的 Facebook.java,然后我进行了如下更改:
public void authorize(Activity activity, String[] permissions,
int activityCode, final DialogListener listener) {
boolean singleSignOnStarted = false;
mAuthDialogListener = listener;
/* // Prefer single sign-on, where available.
if (activityCode >= 0) {
singleSignOnStarted = startSingleSignOn(activity, mAppId,
permissions, activityCode);
}
// Otherwise fall back to traditional dialog.
if (!singleSignOnStarted) {*/
startDialogAuth(activity, permissions);
// }
}
于 2012-08-01T04:40:46.277 回答
2
使用以下代码进行注销:
private void logout(Facebook facebook) {
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.logout(getBaseContext(), new RequestListener() {
@Override
public void onComplete(String response, Object state) {
Log.i("System out", "Logout:onComplete:res:state " + response
+ ":" + state);
new LoginData(SettingsActivity.this).clearFacebookDataInPref();
handler.sendEmptyMessage(1);
}
@Override
public void onIOException(IOException e, Object state) {
Log.i("System out", "Logout:state" + ":" + state);
e.printStackTrace();
exceptionMessage = e.getMessage();
handler.sendEmptyMessage(2);
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
Log.i("System out", "Logout:OnFileNotFoundExce:state:" + state);
e.printStackTrace();
exceptionMessage = e.getMessage();
handler.sendEmptyMessage(2);
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
Log.i("System out", "Logout:MalformedURLExce:state:" + state);
e.printStackTrace();
exceptionMessage = e.getMessage();
handler.sendEmptyMessage(2);
}
@Override
public void onFacebookError(FacebookError e, Object state) {
Log.i("System out", "Logout:onFacebookError:state" + state);
e.printStackTrace();
exceptionMessage = e.getMessage();
handler.sendEmptyMessage(2);
}
});
}
如果您保存访问令牌并在共享首选项上过期,请在 onComplete 侦听器上删除/清除..
于 2012-08-01T05:36:15.023 回答