My app implements OAuth 2.0 using a custom tab and App Link, and obtains data sent with a redirect URL through App Link through onNewIntent().
I'm trying to send a method to send this data to the ViewModel of the Activity along with some data that is sent when displaying this Activity to the server side along with some data stored using SavedStateHandle.
According to my Firebase Crashlytics and customer reports, depending on device, onNewIntent() isn't called, but onCreate(), where a new activity is created, is called.
However, at this time, the data stored in SavedStateHandle doesn't exist, and since it was not created with putExtra(), there is no data and a NullPointException occurs.
I think this is an impossible case based on my knowledge because there are additional settings as shown below, but can I know why a new Activity is created like this?
- The launch mode uses singleTask.
- When displaying an activity, the flag is not set separately.
- Multi module is used and compose is not used.
- We added processing to disable the do not preserve activity mode, so if that happens, the activity will not be reached.
- It is used Kotlin, and the Activity lib version is 1.4.0 and the Lifecycle version is 2.4.1.
- This occurs regardless of OS version and device brand.
Thanks to the comments, I solved it like this.
singleTop.