启动从的WebView定制的Andr​​oid应用 [英] Launch custom Android application from WebView

查看:88
本文介绍了启动从的WebView定制的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有推出一个应用程序,如果我在Android原生浏览器中打开HTML文件, 但是当我试图在web视图打开一样,它不能启动该应用程序,而网页不可用字样。我觉得我的WebView是不是能够处理方案my.special.scheme://定义的应用程序。

I have an HTML file which is launching an app if I open it in the Android native browser, but when I try to open the same in a WebView, it is not able to launch that application, and "Webpage not available" is shown. I think my WebView is not able to handle the scheme "my.special.scheme://" defined for the application.

我读<一href="http://stackoverflow.com/questions/6139508/launching-an-android-application-from-the-browser">Launching从浏览器的Andr​​oid应用程序的,但它不包括有关从web视图启动应用程序的信息。

I read Launching an Android Application from the Browser, but it does not cover information about launching an app from a WebView.

推荐答案

我不知道,但我相信的WebView根本不处理自定义URI方案。

I'm not sure, but I believe that WebView simply doesn't handle custom URI schemes.

解决方法是重写<一个href="http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading%28android.webkit.WebView,%20java.lang.String%29"如果URL使用您的URI方案,启动您的应用程序并返回如果匹配,否则相对=nofollow> WebViewClient.shouldOverrideUrlLoading()和手动测试返回

The workaround is to override WebViewClient.shouldOverrideUrlLoading() and manually test if the URL uses your URI scheme, launching your app and returning true if it matches, otherwise returning false.

这篇关于启动从的WebView定制的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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