android - 如何从 webview 拨打电话 [英] android - How to make a phone call from webview

查看:95
本文介绍了android - 如何从 webview 拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用 webview 打开 url.这个 url 打开一些包含一些电话号码的页面.现在我想打电话,如果你点击电话号码,而不打开电话拨号器.是否可以?请任何人都可以帮助我.

In my app, i am opening the url using webview. This url opens the some page that contains some phone numbers.Now i want to make a phone call without open the phone dialer if u click on the phone number. is it possible? please can anybody help me.

谢谢

推荐答案

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;
    }

这篇关于android - 如何从 webview 拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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