So here is what I am trying to achieve here... We have two android APKs installed on the device... Each APK can force itself to be on the foreground (This is not an app the general public will use so it's okay...)
- So we launch task a with activity a.
- We then launch task b with activity b.
- Then activity a & task a wants to go to foreground (This can happen at any time)
- At some point later, activity a and task a wants to go to foreground
So we had this code working using the following code:
Intent i = new Intent(Variables.context, HomeActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
Great!
However, on a phone running 4.2.2 (and maybe others too) we noticed that the behavior was not as expected. The following two things can happen.
Let's assume activity a & task a is in the foreground, but want to make activity b and task b come to the foreground it does not work.
However if no task was in the foreground and the home launcher is focused, then activity b and task b gets popped to the foreground as expected.
Here is an example of one of my manifest from one of the applications:
<activity
android:name="some.app.id.goes.here"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have tried adding this line of code:
android:launchMode="singleTop"
and it still does not work.
Is there anything I am missing?
A few notes:
- Activity A can be ANY application, not just our developed application which rules out activity A from stopping this from happening. We had the same results using Google chrome / Google maps / Google play store.
- We do not override onNewIntent