开发者

Can I close a browser activity I've opened?

开发者 https://www.devze.com 2023-03-24 18:20 出处:网络
My app opens a browser activity via startActivity(). Can I close that browser activity if I feel like it?

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'.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号