1

the problem: my app on Xiaomi redmi note 9c fails to resume in the correct activity, when I put my app in the background and then try to resume it from the resent list or the launcher icon, the splash screen appears, and then the current activity but with not correctly initialize data (because the activity needs data from another activity that now not in memory)

in the android log, I can see that the app stops logging after it goes to the background

workaround: I created a foreground notification that seems to force the app to stay in memory with no splash screen and the last activity has now correct data

How can I fix that? I can't fix it how can I detect if my app is not in memory and restart it in the main activity instead of current?

notes: all battery settings optimizations are disabled

similar thread 1, similar thread 2, similar thread 3

miui 12.0.10

` buildFeatures { viewBinding true }

compileSdkVersion 31
buildToolsVersion '31.0.0'`
TBA
  • 1,921
  • 4
  • 13
  • 26
  • "because the activity needs data from another activity that now not in memory" - this is the root issue that you need to solve. This has never, ever been a workable solution. – ianhanniballake Jan 25 '22 at 05:22
  • Please post your manifest. The description of your problem sounds a bit strange. – David Wasser Jan 31 '22 at 10:00

1 Answers1

0

Obviously your design is flawed. If you need a certain activity first, make that your launcher activity. From that activity , onResume() etc, you can call the second activity directly with startActivity(new Intent("your second activity"))

CaptainCrunch
  • 1,230
  • 14
  • 15