简体   繁体   English

意外调用 LoginManager.onActivityResult Facebook SDK v3.2

[英]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:我会指出我所做的其他事情:

  • Change public_profile permissions to Advanced将 public_profile 权限更改为高级
  • Change email permissions to Advanced将电子邮件权限更改为高级
  • Added all the SHA1 fingerprints used in firebase to facebook dev, after Hex to Base 64, https://base64.guru/converter/encode/hex将 firebase 中使用的所有 SHA1 指纹添加到 facebook dev,在 Hex 到 Base 64 之后, https://base64.guru/converter/encode/hex
  • Added facebook app id in the manifest, since firebase had its own facebook app id, I used tools:replace="android:value" on that meta data在清单中添加了 facebook 应用程序 id,因为 firebase 有自己的 facebook 应用程序 id,我在元数据上使用了tools: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.

相关问题 onActivityResult请求代码Facebook SDK - onActivityResult requestcode Facebook SDK 在Android SDK中使用facebook.authorize不会调用onActivityResult - Using facebook.authorize with the Android SDK does not call onActivityResult 我可以在jbpm v3.2中将运行时过渡添加到任务节点吗? - Can i add a run time transition to a task node in jbpm v3.2? Spring Web MVC应用程序未在Pivotal tc Server Developer Edition v3.2上运行 - spring web mvc application not running on Pivotal tc Server Developer Edition v3.2 Facebook SDK-如何正确覆盖onActivityResult()? - Facebook SDK - how to override onActivityResult() correctly? Facebook身份验证第二次未调用onActivityResult - Facebook authentication not call onActivityResult from second time Android应用程序:Facebook LoginManager授予我“ publish_actions”权限,但应用程序从未经历过callbackManager回调(Facebook SDK 4.18.0)吗? - Android App: Facebook LoginManager gives me “publish_actions” permission but app never goes through callbackManager callback( Facebook SDK 4.18.0)? 使用 onActivityResult 调用函数 - Use onActivityResult to call a function Activity不会调用onActivityResult - Activity does not call onActivityResult 如何为片段调用onActivityResult - How to call onActivityResult for fragment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM