Launch browser from within app - how do you get back to the app?
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
.
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)
You can't. They have to press the back button to get back to your app.
精彩评论