Killed app relaunches same Activity instead of default Activity
Scenario: Activity A has the LAUNCHER/DEFAULT stuff Activity B also exists
- Launch app, A is shown
- Click on a button that causes B to show
- Click on a button that causes ProcessPhoenix to be invoked
I would expect the app to relaunch with only A showing, but B is relaunched instead. I tried specifying the Intent for A but even that doesn't work. Testing on an Emulator, API 28. Am I doing something wrong or is this a bug? I've combed over the code and can't figure out why this is happening.
Don't have much bandwidth here. Maybe send a PR to the sample to create a similar situation so we can repro?
You should use finishAndRemoveTask as mentioned here:
https://stackoverflow.com/a/27765687/1761406
Kinda +1 for this. Although our problem is that app is crashing just after rebirth. Our scenario is:
HomeActivity -> PreferenceActivity1 -> PreferenceActivity2.
In PreferenceActivity2 we call triggerRebirth() with custom Intent pointing to HomeActivity. The problem is that after the rebirth, the PreferenceActivity1 is for some reason recreated without UI, thus crashing the app, because we call getPreferenceScreen()(which is null) from onResume().
We adjusted ProcessPhoenix to call finishAffinity() instead of finish(), which seems to be working.
Can you update our sample to replicate the problematic behavior in a PR? And perhaps include the fix?
Kinda +1 for this. Although our problem is that app is crashing just after rebirth. Our scenario is:
HomeActivity -> PreferenceActivity1 -> PreferenceActivity2.In
PreferenceActivity2we calltriggerRebirth()with customIntentpointing toHomeActivity. The problem is that after the rebirth, thePreferenceActivity1is for some reason recreated without UI, thus crashing the app, because we callgetPreferenceScreen()(which isnull) fromonResume().We adjusted
ProcessPhoenixto callfinishAffinity()instead offinish(), which seems to be working.
I am a launcher app. I had a problem in Android 7.1, when I restarted the app using the "triggerRebirth" method, a black screen appeared and the activity never reopened.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
finishAffinity();
} else {
finish();
}
Thanks for your answer, it solved my problem.
Kinda +1 for this. Although our problem is that app is crashing just after rebirth. Our scenario is:
HomeActivity -> PreferenceActivity1 -> PreferenceActivity2. InPreferenceActivity2we calltriggerRebirth()with customIntentpointing toHomeActivity. The problem is that after the rebirth, thePreferenceActivity1is for some reason recreated without UI, thus crashing the app, because we callgetPreferenceScreen()(which isnull) fromonResume(). We adjustedProcessPhoenixto callfinishAffinity()instead offinish(), which seems to be working.I am a launcher app. I had a problem in Android 7.1, when I restarted the app using the "triggerRebirth" method, a black screen appeared and the activity never reopened.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { finishAffinity(); } else { finish(); }Thanks for your answer, it solved my problem.
Last week I said that I solved the problem of not being able to restart after changing it this way. In fact, in the end, I tested that it still cannot restart under certain conditions.
So I made the following changes:
binding.reboot.setOnClickListener {
requireActivity().finish()
ProcessPhoenix.triggerRebirth(requireContext())
}
Use requireActivity().finish() before executing triggerRebirth so that even if I don't modify the ProcessPhoenix source code to add finishAffinity(), I can restart the app in any situation.