I am running into issue where onDestroy() invoked for all previous activities when singleInstance activity is running and i minimize my app.
i create a sample App to check this behavior:
my Manifest
<activity
android:name=".MainActivity3"
android:launchMode="singleInstance"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity2"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
and this is whats happend:
I navigate to activity3 by intent:
activity1 -> activity2 -> to activity3 (this launchMode:singleInstance)
and the problem now is when i minimize my app when the singleInstance activity visible -> all activities in stack was destroyed.
and this is the logcat:
D/Hofit: MainActivity1 - onResume
D/Hofit: MainActivity2 - onResume
D/Hofit: MainActivity3 - onResume
D/Hofit: MainActivity2 - onStop
D/Hofit: MainActivity1 - onStop
//activity3 visible and i minimimize
D/Hofit: MainActivity2 - onDestroy
D/Hofit: MainActivity1 - onDestroy
D/Hofit: MainActivity3 - onStop
why this is happend in my app and sample when app gose to background? how can i solve this? why activities destroyed and not just stop?
Thanks!