Open dialer example
suggest changeIf the web page contains a phone number, you can place a call with the phone's dialer. This code checks for a URL that starts with tel:, then creates an intent that opens the dialer for that number. It returns true for every URL, so schemes other than tel:, http:, and https: are not loaded.
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;
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents