okta / okta-oidc-android

OIDC SDK for Android
https://github.com/okta/okta-oidc-android
Other
60 stars 45 forks source link

onConfigurationChange application not able to close OktaAuthenticationActivity to restart the app again. #313

Closed gopalp1709 closed 2 years ago

gopalp1709 commented 2 years ago

Describe the bug?

Hi Team, Our application supports multiple language and sometimes user put app in background with any screen to change language.Normally for this scenario we restart the app to take effect of newly selected language.

Recently we observe our app is not restarting as we are not able to close the OktaAuthenticationActivity onconfiguration change So can you share any handle to kill activity and restart application when configuration changes.

We are using following dependency and OktaAuthenticationActivity with SingleTop.

 implementation 'com.okta.android:okta-oidc-android:1.2.3'
        <activity
            android:name="com.okta.oidc.OktaAuthenticationActivity"
            android:launchMode="singleTop"
            tools:replace="android:launchMode"/>

What is expected to happen?

Application should have some handle to kill OktaAuthenticationActivity to restart the the application.

What is the actual behavior?

OktaAuthenticationActivity is getting refreshed with new language.

Reproduction Steps?

Scenario steps:

  1. App displays Okta browser sign in page to user.
  2. User puts app in background to change language.
  3. User change the language and opens the app from recent apps.
  4. OktaAuthenticationActivity gets refreshed but our application doesn't restart by finishing it.Appli

Additional Information?

No response

SDK Version

implementation 'com.okta.android:okta-oidc-android:1.2.3'

Build Information

implementation 'com.okta.android:okta-oidc-android:1.2.3'

JayNewstrom commented 2 years ago

This sounds like expected Android behavior to me. If you're looking to detect something like this in our app, and kill SDK activities, consider using https://developer.android.com/reference/android/app/Application#registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks) to keep a reference to all activities, so you can finish them.

gopalp1709 commented 2 years ago

OktaAuthenticationActivity's onConfigurationChange method taking priority over my Application and MainActivity class's onConfigurationChange . Due to this even if I keep reference of OktaAuthenticationActivity in my application class, I am not able to kill it and restart the application.Kindly suggest any other alternative so that I can kill OktaAuthenticationActivity and restart my app.

JayNewstrom commented 2 years ago

I'm not able to recreate this. Our activity isn't registered to listen for config changes, so we just do the standard android thing (onDestroy current, onCreate new with new configuration). We have no way to override anything else happening in the app.

If you can give us a sample demonstrating the issue, I'd be happy to take a look.

JayNewstrom commented 2 years ago

Please reopen when you have more information.