1

After showing the webbroser with this code :

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);

How to close it programatically ?

pheromix
  • 18,213
  • 29
  • 88
  • 158
  • I don't think you can close other applications. I'd rather use the [WebView](http://developer.android.com/reference/android/webkit/WebView.html) component and display the page inside the app. – Gerald Schneider Apr 23 '14 at 08:17
  • I think this can be done by only back key event of your device. – Miral Dhokiya Apr 23 '14 at 08:17

2 Answers2

4

How to close it programatically ?

You can't.

It's not under your control. A new activity has been launched and you must wait for the user to stop interacting with it (for example, when they click the back button) for control to return to your activity.

If you want fine-grained control you should probably look at embedding a WebView in your own activity or fragment, then you have full control over opening and closing it.

Ken Wolf
  • 23,133
  • 6
  • 63
  • 84
1

If you mean the Browser App, you may close it by code finding his PID and killing it but is discouraged.

Read this post

Community
  • 1
  • 1
alfdev
  • 1,039
  • 1
  • 10
  • 23