android webview 7.0 h5调用打电话解决方案

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.startsWith("mailto:")) {
        //Handle mail Urls
        startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse(url)));
    } else if (url.startsWith("tel:")) {
        //Handle telephony Urls
        startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
    } else {
        view.loadUrl(url);
    }
    return true;
}
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    final Uri uri = request.getUrl();
    if (uri.toString().startsWith("mailto:")) {
        //Handle mail Urls
        startActivity(new Intent(Intent.ACTION_SENDTO, uri));
    } else if (uri.toString().startsWith("tel:")) {
        //Handle telephony Urls
        startActivity(new Intent(Intent.ACTION_DIAL, uri));
    } else {
        //Handle Web Urls
        view.loadUrl(uri.toString());
    }
    return true;
}

地址:https://stackoverflow.com/questions/4338305/android-webview-tel-links-show-web-page-not-found

你可能感兴趣的:(android)