Android - How to make a phone call from webview

In my application, I open the url using webview. This URL opens a page containing some phone numbers. Now I want to make a phone call without opening the phone number if you click on the phone number. Is it possible? please can someone help me.

thanks

+6
source share
2 answers
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; } 
+9
source

Thanks JackTurky! Here is a bit more to show how it fits with webView:

  webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("tel:")) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); startActivity(intent); return true; } return false; } }); 
0
source

Source: https://habr.com/ru/post/909158/


All Articles