Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I close a browser activity I've opened?

My app opens a browser activity via startActivity(). Can I close that browser activity if I feel like it?

For one thing, startActivity() does not return anything - can I get an Activity object back from it somehow?

In the JavaScript world, the convention is that whoever opened a new browser window has the authority to close it. Just sayin'.

like image 212
Seva Alekseyev Avatar asked Aug 03 '11 13:08

Seva Alekseyev


People also ask

How do I delete my activity history?

On your Android phone or tablet, go to myactivity.google.com. Above your activity, tap Delete . Tap All time. Delete.

How do you delete old activity on Android?

startActivity(intent); It will totally clears all previous activity(s) and start new activity.


4 Answers

I think you getting hopefully answer from this post

Starting an ACTION_VIEW activity to open the browser, how do I return to my app?

Clear back stack after activity is opened from web-browser by url "appname://com.appname/"

like image 112
Pratik Avatar answered Sep 23 '22 04:09

Pratik


No you can't. You don't have control over browser activity. You can use WebView to embed the browser in custom activity on which you'll have full control and call finish() when you want.

like image 22
Mojo Risin Avatar answered Sep 21 '22 04:09

Mojo Risin


As outlined here, if you activate the root activity with the following intent flags:

Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP

it will finish all activities on top of it in the navigation stack. Including the browser.

like image 37
Seva Alekseyev Avatar answered Sep 24 '22 04:09

Seva Alekseyev


No you can not get a handle for the Activity object.


VERY DANGEROUS

Try using a Handler or any other way to send a backspace key which usually closes the activity. Will it work?

However keep in mind that this is completely wrong

like image 25
Sherif elKhatib Avatar answered Sep 20 '22 04:09

Sherif elKhatib