Reputation: 23676
Our app has 2 Activities- A MainActivity
(associated with Launcher icon) and an AuxActivity
for handling URI events.
I'm seeing an issue with this scenario, with my app initially exited:
Open Browser, click on a URI to launch the AuxActivity
.
AuxActivity
exits (calls finish()), user returns to Browser.
User brings up recent Apps (long-press home), and selects my app.
Instead of starting MainActivity
, I'm seeing AuxActivity
being started with the same intent that represents a URI click (android.intent.action.VIEW
).
Now instead of step 3, if the user were to open my app through its Home Screen icon, I get back to MainActivity
, as expected.
How can I get step 3 to launch MainActivity
instead?
Upvotes: 4
Views: 456
Reputation: 5229
Put this in AuxActivity's onCreate:
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) > 0) {
// do something different e.g. launch MainActivity
}
Upvotes: 2
Reputation: 21567
Not sure if this will work, but you might also try:
android:noHistory="true"
Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it's no longer visible on screen — "true" if it should be finished, and "false" if not. The default value is "false". A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it. This attribute was introduced in API Level 3.
Upvotes: 1
Reputation: 7860
Based on Tim's suggestion, what about adding
android:excludeFromRecents="true"
To the auxActivity listing in the Manifest? Does that help?
Upvotes: 1