问题
My entire project was built in Portrait mode with all my activities set with the following option in the AndroidManifest.xml:
android:screenOrientation="portrait"
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.
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 ?
回答1:
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>
来源:https://stackoverflow.com/questions/59258492/onactivityresult-for-createsigninintentbuilder-not-called-when-invoked-in-land