Android的Facebook.authorize不叫的onComplete方法 [英] Android Facebook.authorize don't call oncomplete method
问题描述
我想整合Facebook登录我的Android应用程序。我发现了很多在互联网上的例子,但现在我有以下问题,我无法找到一个解决方案。
I'm trying to integrate facebook login on my android app. I found a lot of examples on internet, but now I have the following problem and I can't find a solution.
在facebook.authorize收工时,onComplete方法不会被调用。 如果我使用facebook.authorize与Facebook.FORCE_DIALOG_AUTH,在这种情况下,调用onComplete方法,我可以保存access_token。 我附上我的code一个文档片断。 谁能帮我解决这个问题?
After facebook.authorize finish work, the oncomplete method is never called. If I use the facebook.authorize with Facebook.FORCE_DIALOG_AUTH, in this case the oncomplete method is called and I can save the access_token. I attach a snipped of my code. Can anyone help me to solve this problem?
if(!facebook.isSessionValid()) {
facebook.authorize(Login.this, new String[] {"publish_stream","read_stream", "offline_access"}, //Facebook.FORCE_DIALOG_AUTH,
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) {Log.e("FB:","Facebook Error" );}
@Override
public void onError(DialogError e) {Log.e("FB:","Error" );}
@Override
public void onCancel() {}
});
}
谢谢 斯莫
推荐答案
请确保你实施<一个href="http://developer.android.com/reference/android/app/Activity.html#onActivityResult%28int,%20int,%20android.content.Intent%29"><$c$c>onActivityResult()$c$c>正确地作为官方文档:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
这篇关于Android的Facebook.authorize不叫的onComplete方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!