Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

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

In my app i need to open the bank's page, to make the user able to pay. Reading the Android documentation I see that I should use an ACTION_VIEW (and not a WebView) to accomplish this.

 Uri uri = Uri.parse("http://www.example.com");
 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 startActivity(intent);

My question is: After the user is done with the payment, how can i get back to the app?

I mean, I'd like to do something like

startActivityForResult(intent, RESULT_CODE);

to open the bank's site, and then get back to the app when the user is done, using the

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

callback to handle the result of the payment.

And, am I following the right way? Or is there any other way to accomplish this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How would the browser know that user is done with the bank page? It has no way to know that.

Also, browser does not react to startActivityForResult() by setting result and then finish().

So, you can not use Android browser to accomplish this task.

The only possible way would be to start WebView and to detect when user is finished, by detecting certain url that is (supposedly) shown when user is finished with the bank task.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...