3

I've got the following to open up a browser from within an Android app.

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

How do you get the user back to the app after they have viewed the page?

Edit

I have android:noHistory="true" set in my manifest for the Activity calling the Intent.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
Garbit
  • 5,805
  • 6
  • 39
  • 72

2 Answers2

4

If the calling Activity is in the Backstack (as default) the user would press "back" to peal the top layer off the stack.

However if the browser closes, the Activity does too, and the last Activity in the Backstack comes to the fore. If you own the site your going to and can put a "back" button in it (With javascript window.close() or similar), the activity will close and your applications topmost activity in the stack will resume.

If your Activity isn't in the backstack then I would suggest instead of sending the user to the browser Task use a custom Activity containing a WebView giving you full control (such as manually starting the original Activity through an Intent)

Graeme
  • 25,714
  • 24
  • 124
  • 186
1

You can't. They have to press the back button to get back to your app.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84