Reputation: 4338
Activity A is a splash screen. Activity B is a menu screen that is singleTask. Activity C is a screen with noHistory that selects a photograph from the gallery with the built-in intent for choosing a photograph. Activity D is a screen that manipulates photographs.
The problem that I have is that when I am in Activity D and select the home button, if I choose the application to be launched once more it returns me to Activity A to launch Activity B again instead of launching Activity D where I left off. If I use the recent apps however, it switches back to Activity D just fine as expected. So, there must be something slightly error prone in the way that I have it setup. But, I should expect it to return to Activity D in both cases so that the user can keep coming back to the Photo viewing screen (Activity D).
Thoughts?
<activity
android:name="ActivityA"
android:theme="@style/Theme.CustomDefaultStartup"
android:noHistory="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="sensorLandscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="ActivityB"
android:theme="@style/Theme.CustomDefault"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask">
<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
android:name="ActivityC"
android:theme="@style/Theme.CustomDefault"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name">
</activity>
<activity
android:name="ActivityD"
android:theme="@style/Theme.CustomDefault"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name">
</activity>
Upvotes: 2
Views: 668
Reputation: 4338
Apparently it was the android:launchMode="singleTask"
on Activity A that was causing the problems. Once, the singleTask from the splash screen was removed, the behavior returned as was expected. Not sure where the singleTask for the splash screen came from, but it was probably an error left in place for a while in the application.
Once that was removed, Activity D no longer launched the splash screen and the following menu after a home button press and return to the application. While I do not follow this completely as to why this would cause it in the lifecycle of events, this resolved the issue for me.
Upvotes: 2