I'm experiencing a strange issue on a new app I'm currently developing, where if I send the app to background (Home button), and then relaunch the app using the App Icon, all activities, except for the root activity are destroyed (on log I get OnDestroy for all activities, except for the root activity where OnResume is called).
If I send it to background and resume it from the current tasks, it resumes the app.
I have added android:launchMode="singleTask" to all the activities on the app manifest but it made no difference.
Every activity is started normally: startActivity(new Intent(this, nextClass));
Is there any way to resume the app when pressing the App Icon instead?
AndroidManifest.xml
<application
tools:replace="android:icon"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation|screenSize"
android:name="com.example.game.classes.App">
<activity
android:name=".LaunchScreenActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:launchMode="singleTask"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:launchMode="singleTask"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity
android:name=".PlayActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:launchMode="singleTask"
android:configChanges="keyboardHidden|orientation|screenSize" />
.
.
.
EDIT: Explanation to as not duplicate of App restarts rather than resumes
The difference between that situation and mine is that, on that case the main activity is launched on top of the other activities (you can press back to return to previous running activities). In my case the other activities are completely destroyed except for the launch activity which is resumed.
After days searching for a solution.. I finally found the problem.
The issue was adding android:launchMode="singleTask" to every activity.
I removed it from all activities except from the root activity and now it is working as I wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With