[英]Unexpected call to LoginManager.onActivityResult Facebook SDK v3.2
I am integrating the Facebook Login in my Android Application and when I click on the Login button and allow the required permission it gives me Unexpected call to LoginManager.onActivityResult .我正在将 Facebook 登录集成到我的 Android 应用程序中,当我单击“登录”按钮并允许所需的权限时,它会意外调用 LoginManager.onActivityResult 。
permissions that I am requesting are "public_profile","business_management","read_insights"我请求的权限是“public_profile”、“business_management”、“read_insights”
I have followed all the instruction as per this question but still facing the same error我已经按照这个问题遵循了所有说明,但仍然面临同样的错误
Facebook Android SDK v2.3 Unexpected call to LoginManager.onActivityResult Facebook Android SDK v2.3 意外调用 LoginManager.onActivityResult
public class FacebookLogIn extends AppCompatActivity implements View.OnClickListener {
private static final String TAG = "FacebookLogIn";
private List<String> permissions = Arrays.asList("public_profile","business_management","read_insights");
private CallbackManager callbackManager;
ViewPager viewPagerFragment;
SplashViewPagerAdapter viewPagerAdapter;
Button btnLogin;
FrameLayout frameLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
viewInIt();
viewPagerSetUp();
doAuth();
//automatically logIn if access Token available and not expired else perform doAuth().
AccessToken accessToken = MyTokens.getAccessToken();
boolean isLoggedIn = accessToken != null && !accessToken.isExpired() && accessToken.getPermissions().contains("read_insights") && accessToken.getPermissions().contains("business_management");
if (isLoggedIn){
//if access token not expired and permission granted then start AppSelection Activity
startActivity(new Intent(FacebookLogIn.this, AppSelection.class));
//and close the current activity
finish();
}
}
private void viewInIt(){
btnLogin=findViewById(R.id.btnFbLogin);
btnLogin.setOnClickListener(this);
}
/*
--------------------------------------Login button------------------------------------------------------
*/
@Override
public void onClick(View v) {
LoginManager.getInstance().logInWithReadPermissions(this, permissions);
}
private void doAuth() {
//callbackManager for facebook logIn
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
//start AppSelection Activity
startActivity(new Intent(FacebookLogIn.this,AppSelection.class));
//and close the current activity
finish();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException exception) {
exception.printStackTrace();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
I am getting this error code when press the Login button allow the permission当按下登录按钮允许权限时,我收到此错误代码
W/System.err: Unexpected call to LoginManager.onActivityResult
W/System.err: at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:232)
at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:174)
W/System.err: at com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.java:91)
at com.greenlab.audiencenetwork.FacebookLogIn.onActivityResult(FacebookLogIn.java:110)
at android.app.Activity.dispatchActivityResult(Activity.java:7121)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4175)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4222)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1581)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6238)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
I had the same error, and did a lot til it worked, however I might not be able to say specifically what fixed it, but its probably not code.我有同样的错误,并做了很多直到它起作用,但是我可能无法具体说明修复它的原因,但它可能不是代码。 My best guess is you need to Verify your Dev Account as Individual or Business Account https://developers.facebook.com/docs/development/release/individual-verification As written, the changes take effect immediatetely, so when I got the email that my account was verified successfully, I went to my app, tried the oAuth, it worked.
我最好的猜测是您需要将您的开发帐户验证为个人或企业帐户https://developers.facebook.com/docs/development/release/individual-verification正如所写,更改立即生效,所以当我收到电子邮件时我的帐户已成功验证,我去了我的应用程序,尝试了 oAuth,它奏效了。
I'll point out other things I did:我会指出我所做的其他事情:
tools:replace="android:value"
on that meta datatools:replace="android:value"
So whether its all of them or one of them, I encourage you to check the list.因此,无论是全部还是其中之一,我都鼓励您查看列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.