I think that App Manager runs my application after installation in wrong way. It runs my applications in its task. When I press HOME and press application icon I runs second task with my application.
I tested it. I made two applications App1, App2. App2 has two activities A and B. App1 runs App2 in the simplest way.
Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(new ComponentName("org.app2.test", "org.app2.test.Screen1"));
Test 1. Run App1. App1 runs App2 activity A. Acctivity A runs activity B. Press Home. Press App2 icon. You can see App2 activity A. (Wrong. We have to Tasks with App2)
That I changed code for launching App2.
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName("org.app2.test", "org.app2.test.Screen1"));
Test 2. Run App1. App1 runs App2 activity A. Acctivity A runs activity B. Press Home. Press App2 icon. You can see App2 activity B. (Ok.)
How can I change App2 manifest and force App2 always run in its own task?
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Screen1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2">
<intent-filter>
<action android:name="org.app2.test.screen2" />
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
I detects situation of first run of application and restarts it.