How to open Dialer Activity from a webviewclient with clicked number?

谁说胖子不能爱 提交于 2019-12-08 04:06:26

This must be working. we need to override the shouldOverrideUrlLoading method of the webview class. and check if the url contains the tel:xxxx Then create an intent for the dialer and invoke the dialer. and we can call any application we want like gmail app if its a mailto: link

here is the methode.

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
   if(url.contains("tel:")) {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse(url));
        startActivity(intent);
        return true;
   } else {
        progressBar.setVisibility(view.VISIBLE);
        view.loadUrl(url);
        return true;
   }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!