title: How to fix that my app partial restarts rather than resumes?
body: <p>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)</p>
  <p>in the android log, I can see that the app stops logging after it goes to the background</p>
  <p>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</p>
  <p>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?</p>
  <p>notes: all battery settings optimizations are disabled</p>
  <p><a href="https://stackoverflow.com/questions/19545889/app-restarts-rather-than-resumes">similar thread 1</a>,
  <a href="https://stackoverflow.com/questions/60557209/app-restarts-main-activity-from-background-instead-of-resuming-previous-state">similar thread 2</a>,
  <a href="https://stackoverflow.com/questions/30395543/android-activity-lifecycle-restarting-app-instead-of-restart-activity">similar thread 3</a></p>
  <p>miui 12.0.10</p>
  <p>`    buildFeatures {
  viewBinding true
  }</p>
  <pre><code>compileSdkVersion 31
  buildToolsVersion '31.0.0'`
  </code></pre>