开发者

How to close browser activity when returning to calling activity?

I have this situation. I have an Activity A that sends an intent to create an Activity B which is a browser to authenticate a user with his twitter account. When credentials are submitted the control goes back again to Activity A and I can keep navigating through the app. However, if the users leaves the app, the browser activity is being resumed, forcing the user t开发者_如何学Pythono close the browser.

The problem is that I would like to remove the browser activity from the stack once I get the authentication credentials.

Do you know if this is possible? I cannot use startActivityForResult since the authentication needs to be made in the browser, I don't have any control over that activity. Thanks a lot

EDIT:

I'm starting the activity like this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)).setFlags(Intent.FILL_IN_ACTION));


Maybe you could put something in OnResume() in Activity B which checks if this is the first activation of Activity B, and closes it automatically if it isn't?

Update: You could alternatively use an AsyncTask to post the credential info to the website, using a DefaultHttpClient and HttpPost. Unfortunately I've only used HttpGet in this scenario, but there is some code here that may be of use.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜