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'.
On your Android phone or tablet, go to myactivity.google.com. Above your activity, tap Delete . Tap All time. Delete.
startActivity(intent); It will totally clears all previous activity(s) and start new activity.
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/"
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With