[英]Why absolutely nothing happens after calling onActivityResult() on the CallbackManager using the Facebook Login Button?
I've been trying to figure out how to solve this but was unsuccessful. 我一直试图弄清楚如何解决这个问题但是没有成功。
The problem here is after clicking the login button, it loads the Facebook Activity normally, and when it finishes, my activity receives the activity result and notifies the CallbackManager (all as described in the docs). 这里的问题是在点击登录按钮后,它正常加载Facebook活动,当它完成时,我的活动收到活动结果并通知CallbackManager(所有文档中描述的)。
Unfortunately nothing happens from this point, no method from the registered FacebookCallback is executed, and not even a line is logged to inform of an error. 不幸的是,从这一点来看没有任何事情发生,注册的FacebookCallback没有执行任何方法,甚至没有记录一行来通知错误。
Here are the involved files: 以下是涉及的文件:
public class LoginActivity extends Activity
CallbackManager callbackManager;
LoginButton loginFacebook;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this);
setContentView(R.layout.activity_login);
...
callbackManager = CallbackManager.Factory.create();
loginFacebook = (LoginButton) findViewById(R.id.login_button);
loginFacebook.setReadPermissions("public_profile","email");
loginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
...
(This is never executed)
}
@Override
public void onCancel() {
...
(Not executed)
}
@Override
public void onError(FacebookException e) {
...
(Not executed either)
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(resultCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
...
}
And activity_login.xml includes the button like this activity_login.xml包含这样的按钮
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"/>
I also added the Facebook Activity and APP ID in my android manifest file 我还在我的android清单文件中添加了Facebook Activity和APP ID
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
As well as the android app key in the facebook application. 以及facebook应用程序中的android app键。
Hope figures out a solution for this, thank you very much. 希望找到解决方案,非常感谢。
Ok I see now. 好的,我现在看到了。 This is probably wrong
这可能是错的
callbackManager.onActivityResult(resultCode, resultCode, data);
See resultCode
is entered twice. 请参阅
resultCode
两次输入。 What you want to do is: 你想要做的是:
callbackManager.onActivityResult(requestCode, resultCode, data);
Try adding this in your manifest.xml between application 尝试在应用程序之间的manifest.xml中添加它
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" /><activity
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.