[英]Unexpected call to LoginManager.onActivityResult - Facebook SDK Android
My Dependency我的依赖
dependencies {
implementation 'com.facebook.android:facebook-login:11.0.0'
}
I've been using a LoginButton
for moths without any problem but since today after call to login
if the users have not logged before in my app the login flow seems to works fine but the onError
method of my FacebookCallback
is called and I have the next error Unexpected call to LoginManager.onActivityResult
and the second time that I call login
it works and I don't have the Unexpected call to LoginManager.onActivityResult
error.我一直在使用
LoginButton
for moths 没有任何问题,但从今天开始,如果用户之前没有在我的应用程序中登录,则在调用login
后,登录流程似乎工作正常,但调用了我的FacebookCallback
的onError
方法,我有下一个error Unexpected call to LoginManager.onActivityResult
和我第二次调用login
它工作,我没有Unexpected call to LoginManager.onActivityResult
错误。
Here the complete code of my Activity这是我的活动的完整代码
package app.meedu.flutter_facebook_auth;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
public class MainActivity extends AppCompatActivity {
private final CallbackManager callbackManager = CallbackManager.Factory.create();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final LoginButton button = (LoginButton) findViewById(R.id.login_button);
button.setPermissions("public_profile,email");
button.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.i("GOOD::","exito");
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
Log.i("ERROR::",exception.getMessage());
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
}
Your project might be in development mode, switch to live mode might solve the problem您的项目可能处于开发模式,切换到实时模式可能会解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.