[英]Unknow URL Scheme from webView "tel:"
handsome英俊
I tried to Intent "action_dial" from webview.我试图从 webview 意图“action_dial”。 It doesn't perfectly works.它并不完美。 When I click "href tag", it open error page then call dial page,too.当我单击“href 标签”时,它也会打开错误页面然后调用拨号页面。 error page message is "unknown_url_scheme".错误页面消息是“unknown_url_scheme”。 please help me请帮我
Here is my code这是我的代码
<a href= "tel:02-6285-0085"> 02-6285-0085</a>
Android Android
webview.setWebViewClient((WebViewClient) (new WebViewClient() {
public boolean shouldOverrideUrlLoading(@NotNull WebView view, @NotNull WebResourceRequest request) {
Uri uri = request.getUrl();
if (uri.getScheme().equals("tel")){
try {
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent); //
}catch (Exception ex) {
ex.printStackTrace();
}
}
return false;
}
}));
Try once if condition need to change in your current code.如果当前代码中的条件需要更改,请尝试一次。
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent); //
}catch (Exception ex) {
ex.printStackTrace();
}
}
}
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.