您的位置:首页 > 移动开发

android - How to make a phone call from webview

2015-05-07 11:04 716 查看
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}


转载:http://stackoverflow.com/questions/9408378/android-how-to-make-a-phone-call-from-webview

OK so I solved the issue I think. I just needed to separate the URL overrides as follows:
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}


Now my regular links work as well as the tel links. I can also add in there for geo: links if I need to and it will not give me the issue that I was having before to open up maps on the phone.

参考:http://stackoverflow.com/questions/4338305/android-webview-tel-links-show-web-page-not-found
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: