Not adding a new Activity to the current Activity stack

248 Views Asked by At

I'm sure this has been covered but I can't find it anywhere, I basically have a launcher app that fires off to the market place when I select an item. When the user navigates away from the app though and then comes back to it can still show the market place which Activity as that's at the top of it's stack which is something I don't want it to do. So rather than,

App Main Activity

User clicks item to open market place

Market place opens

User hits home and does some other stuff.

User re-opens the app and it takes the user to the last activity in the stack which is the market place.

I want it to go instead

App Main Activity

User clicks item to open market place

Market place opens

User hits home and does some other stuff.

User re-opens the app and it returns to the apps main activity.

Now I could do this in code if the market place activity was part of my app but it's not so I'm a bit stuck.

Thanks a lot.

1

There are 1 best solutions below

0
On BEST ANSWER
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

The key is the FLAG_ACTIVITY_NEW_TASK. This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them.