如何从webviewclient打开拨号活动? [英] How to open Dialer Activity from a webviewclient?

查看:114
本文介绍了如何从webviewclient打开拨号活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用webviewclient打开html页面。 html页面有一个锚标签。
当我点击锚标记我的电话拨号器活动应该启动。
当我在外部浏览器(android默认浏览器)中点击这个锚标签时,它启动了电话拨号器,但是因为我正在使用webviewclient(在我的应用程序中使用浏览器)。我无法启动电话拨号器。

I am using webviewclient to open the html page. The html page is having a anchor tag. when i click on the anchor tag my phone dialer activity should be launched. when i click on this anchor tag in external browser (android default browser ), it is launching the phone dialer, but as i am using the webviewclient (browser with in my application). i am unable to launch the phone dialer.

有什么方法可以使用webviewclient来实现这个功能吗?

is there any way to achieve this using webviewclient ?

推荐答案

您应该重写此方法

You should override this method

public boolean shouldOverrideUrlLoading(WebView wv, String url)
{
    if(isNumber)
    {
        //Get the number from the URL
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:12345"));
        startActivity(intent);
        return true;
    }
    return false;
}

在WebViewClient中,并返回ture,这意味着您要自己处理而不是webView。

in the WebViewClient, and return ture that means you want to handle this by yourself instead of the webView.

该文件是这里

这篇关于如何从webviewclient打开拨号活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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