Search code examples
androidwebview

android - How to make a phone call from webview


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.

thanks


Solution

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