启动一个ACTION_VIEW活动打开浏览器,我怎么回我的应用程序? [英] Starting an ACTION_VIEW activity to open the browser, how do I return to my app?

查看:304
本文介绍了启动一个ACTION_VIEW活动打开浏览器,我怎么回我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我需要打开银行的网页,使用户能够支付。 读了Android文档我看到,我应该使用 ACTION_VIEW (而不是一个的WebView)来实现这一点。

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);

我的问题是:当用户用支付完成后,我怎样才能回到应用程序

我的意思是,我愿意做这样的事情

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?

推荐答案

如何将浏览器知道用户与银行的页面做了什么?它没有办法知道。

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

此外,浏览器不设置结果,然后完成反应 startActivityForResult()()

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

所以,你不能使用Android浏览器来完成这一任务。

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

的唯一可能的方式是将启动web视图并通过检测当用户完成与银行任务是(据说)所示某些网址时用户完成,以检测

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.

这篇关于启动一个ACTION_VIEW活动打开浏览器,我怎么回我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆