在横向模式下调用时,不会调用createSignInIntentBuilder()的onActivityResult [英] onActivityResult for createSignInIntentBuilder() not called when invoked in landscape mode

本文介绍了在横向模式下调用时,不会调用createSignInIntentBuilder()的onActivityResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的整个项目是在纵向模式下构建的,所有活动都通过AndroidManifest.xml中的以下选项进行设置:
android:screenOrientation ="portrait"

My entire project was built in Portrait mode with all my activities set with the following option in the AndroidManifest.xml:
android:screenOrientation="portrait"

但是,由于无法在FirebaseUI上设置方向(如此处所述),用户有机会以横向模式登录.发生这种情况时,永远不会调用onActivityResult:

However, as setting orientation on FirebaseUI is not possible (as described here), there is a chance for users to SignIn in Landscape mode. When this happens, onActivityResult is never called:

 public void createSignInIntent() {
    // [START auth_fui_create_intent]
    // Choose authentication providers
    List<AuthUI.IdpConfig> providers = Arrays.asList(
            new AuthUI.IdpConfig.EmailBuilder().build(),                
            new AuthUI.IdpConfig.GoogleBuilder().build()
            ,new AuthUI.IdpConfig.FacebookBuilder().build()                
    );


    // Create and launch sign-in intent
    startActivityForResult(
            AuthUI.getInstance()
                    .createSignInIntentBuilder()
                    .setAvailableProviders(providers)
                    .setTheme(R.style.FirebaseTheme)                        
                    .setLogo(R.drawable.logofirebase_9)
                    .build(),
            RC_SIGN_IN);

}

// [START auth_fui_result]
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // NEVER REACHING TO THIS POINT IN LANDSCAPE MODE.

    super.onActivityResult(requestCode, resultCode, data);



    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);

        if (resultCode == RESULT_OK) {
            // Successfully signed in

        ...

纵向模式下的行为:用户按下任何登录"按钮,然后过程完成.

Behavior in Portrait Mode: User presses any of the Sign in buttons, and the process goes through.

横向模式下的行为:用户按下任何登录"按钮(即,使用Facebook登录),该过程似乎正在尝试登录用户(显示了加载的带圆圈的动画),但几秒钟后仍然如此FirebaseUI再次显示.

Behavior in Landscape Mode: User presses any of the Sign in buttons (ie. Sign in with Facebook), the process seems to be trying to login the user (the loading circled animation is shown) but after a few seconds the same FirebaseUI is displayed again.

为什么会这样,我该如何解决呢?

Why is this happening and how can I solve the issue ?

推荐答案

通过在AndroidManifest.xml中的FirebaseUI Activity上设置android:configChanges标志来解决,如下所示:

Solved by setting the android:configChanges flag on FirebaseUI Activity in AndroidManifest.xml as shown below:

    <activity android:name=".FirebaseUIActivity"
        android:configChanges="orientation|screenSize|keyboardHidden">
    </activity>

这篇关于在横向模式下调用时,不会调用createSignInIntentBuilder()的onActivityResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆