Click Common tag a contains 'tel:' Uri in HTML cannot start a intent in Android.
这是我的 Android 代码:
WebSettings webSettings = mWebView.getSettings();
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //no cache
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
//This method will only be invoked with GET request
mWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//Log.d("DEBUG-URL","url:"+url);
if(url.startsWith(WebView.SCHEME_TEL)){
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
return true;
}
view.loadUrl(url);
return true;
}
});
当我在 WebView 中单击 url 时,net: ERR_UNKNOWN_URL_SCHEME 抛出。
最佳答案
我添加点击事件,调用 event.preventDefault(),然后使用 Ajax GET 请求。此问题已解决。
$("#a_get").on("click",function(event){
event.preventDefault();//invalidate
$.ajax({
type: "GET",
url: a_href,
success: function(result){
},
error: function(result){
}
});
});
关于Android WebView 标记无法使用 tel Uri 启动 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43691000/