After changing app launcher icon to a new one with activity-alias
method, I exit from app via back button, and when I try to start app from recent apps (Recent Tasks) in android 5.0+, app won't launch. and in some source codes it toasts: "Could not start " and to my case even not toast anything.
but there is an app Textra SMS, which can change launcher icon and after changing Icon, app starts normally even from recent apps.
how can solve this issue?
here is AndroidManifest.xml
code:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity-alias
android:name="com.sid.appiconlauncher.MainActivity-Red"
android:enabled="true"
android:icon="@mipmap/ic_launcher_red"
android:label="@string/app_red"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<activity-alias
android:name="com.sid.appiconlauncher.MainActivity-Green"
android:enabled="false"
android:icon="@mipmap/ic_launcher_green"
android:label="@string/app_green"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<activity-alias
android:name="com.sid.appiconlauncher.MainActivity-Blue"
android:enabled="false"
android:icon="@mipmap/ic_launcher_blue"
android:label="@string/app_blue"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
</application>
I solve this problem by preventing app from close by adding moveTastToBack()
method in onBackPressed()
without calling super
method in root activity:
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
}
with this, app not close, but move to back, like when you click on home button and never this issue happened.