Bytecode
Bytecode

Reputation: 6591

Hide Activity without finish()

I want my application to launch another activity/application (in this case, the Browser application), but currently when the user presses the Back button to exit the Browser, they return back to my Activity.

How can I make it so they do not come back to my activity after leaving the Browser, but if they relaunch my application later, the Activity stack of my application is as it was previously (i.e., cannot finish(), because that will remove the current Activity from the stack)?

Upvotes: 16

Views: 20801

Answers (2)

Bytecode
Bytecode

Reputation: 6591

in Activity.onActivityResult() of the Activity that launched the Browser, call moveTaskToBack(true). Note: this requires that the Browser was launched with Activity#startActivityForResult()

Upvotes: 18

Joe
Joe

Reputation: 42155

You can't control that -- it's an inherent feature of the operating system, and you're talking about affecting behaviors of other applications. The best you can do is control the behavior of your own application. If you need fine-grained control over what you want the user to be able to do in the web browser, have you considered using a WebView instead?

Upvotes: 0

Related Questions