I've inherited a project that starts activity A which in turn starts activity B. If I press the Android Home button and then click on the app icon again, I get activity A vs B.
Looking at the life cycle I'm seeing this.
Click Icon ->Activity A Launch->onCreate->onStart->onResume
Click on context menu that starts Activity B->onCreate->onStart->onResume
Click on Android Home Button Activity B->onPause
Click on App Icon on the Android Home Screen (to resume)
Activity B's onDestory is called followed by Activity A ->onCreate->onStart->onResume.
Any high level thoughts as to what to look for that would cause the onDestroy vs onResume?
Manifest Declarations:
Activity A
<activity
tools:replace="android:theme,android:label"
android:name="WebViewActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name_pro"
android:launchMode="singleTask"
android:theme="@style/MyTheme.AppCompat.NoAB">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter"/>
</activity>
============================
Activity B
<activity
android:name="OwaViewerActivity"
android:label="@string/owa"
tools:replace="android:theme"
android:launchMode="singleTop"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/MyTheme.AppCompat.NoAB"
android:parentActivityName="WebViewActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="WebViewActivity"/>
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
So when in doubt, create a simple app. Turns out that the home button does generate an onStop and then should if the icon is tapped to relaunch, call onStart and on Resume. Turns out the SingleTask is what is causing the onDestory to happen. If I remove the SingleTask the app works as it should. Now I have to go back and find out why the legacy code was using Single Task!