I got 2 activities, say A and B, A is started as usual through the launcher icon. B on the other hand is started through BroadcastReceiver
. The thing I don't really understand here is when activity B is destroyed then activity A is opened? I just can't see the connection in this, and this behavior is not wanted. I've solved this problem before by disabling history on activity A but new functionality enforces history to be used so another solution is needed for this.
Activity declaration in manifest:
<activity android:name="com.example.A"
android:noHistory="false" android:launchMode="singleTask"
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="com.example.B" android:noHistory="true"
android:screenOrientation="portrait" android:label="@string/APP_NAME">
</activity>
And how activity B is launched from BroadcastReceiver
:
Intent intent = new Intent(context, B.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.getApplicationContext().startActivity(intent);
I just don't really get how activity B finds it way to activity A after B is destroyed? How could this be prevented?