查看https://developer.chrome.com/multidevice/android/intents那么从应用程序将结果返回到 Chrome 浏览器的最佳方法是什么?有 browser_fallback_url 但有任何类型的 result_callback 处理程序吗?问题类似于 How to get a result back to your web page from an Intent triggered from inside Chrome?
编辑:为此 https://code.google.com/p/chromium/issues/detail?id=572067 开始发布
最佳答案
Chrome 不会以 startActivityForResult
启动 Activity 因此没有简单的方法可以让接收应用程序直接回调到网站或 Web 应用程序,并像您期望的那样在本地进行响应。
虽然有一个解决方案,但它需要 native 应用程序同意该协议(protocol)。
ZXing QR Code Scanner支持使用名为 ret
的简单查询字符串参数将 QR 码扫描结果回调到站点
On Android, you can invoke Barcode Scanner from a web page and have the result returned to your site via a callback URL. For example, when 01234 is scanned, to have the user return to http://foo.com/products/01234/description, simply link to a URL like this, where {CODE} is a placeholder for the value of the returned code:
Note that the URL in the ret= parameter is URL-escaped, and that {CODE} is used as a placeholder for the scanned value (above, it appears as %7BCODE%7D). SCAN_FORMATS, and other parameters, can be set here as well to control the scan behavior. For example is can be used to supply a comma-separated list of format names.
您可以在 native 应用程序和 Web 应用程序中设置类似的方案,以便在 native 应用程序中完成操作并使用名为 ret
的查询字符串参数启动时(或任何你想要的)然后它知道它需要启动一个新的 Activity 并在 Intent 中设置回调 URL 并在查询字符串中添加额外的数据,这样你的浏览器将打开它需要的所有数据。
它确实有一些问题:
- 您不能定位一个窗口,因此可能会打开一个新窗口,然后您将打开您的网络应用程序两次
- 您需要网络应用和 native 应用来支持如何返回数据的约定。
关于android - 您如何调用 Android 应用程序并从 Chrome 中的网页返回结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34197933/