I have looking for the some suggestions for back to last opened activity when launch from app icon. But still has some side effects to handle.
LauncherActivity is the entry activity which listen for
<activity
android:name="com.app.ui.LauncherActivity"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask"
android:screenOrientation="nosensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Then there is another second activity and third activity.
My scenario is as below:
1. LauncherActivity -> SecondActivity
2. SecondActivity -> ThirdActivity (When launching ThirdAcitivity, SecondActivity will finish itself)
So when at ThirdActivity, user click home key. If the app is opened from recentTask, then the last opened ThirdActivity will be shown. This is the behavior what i want.
But when the app is opened from the app icon shortcut, then it take to the LauncherActivity. But i want it to be the same behavior as recentTask. If the last opened ThirdActivity is not being destroyed, then it should show this one instead of LauncherActivity.
However if the app force stop and then restart or ThirdActivity is being destroyed, then no need to go back to ThirdActivity. Back to LauncherActivity is ok.
I have been looking for solution. The suggestion of saving last activity to sharedPreference is not good for my case.
I would like to know how to achieve like launch from recent task. Is any one can guide me. Thanks a lot.