I am building an android application. I am showing external webpage in webview. I have followed these steps:
There is an option in example.com site to launch Dialer app on button click. Here is the code.
<div class="center"> <input type="image" src="btn.png" onclick="location.href='tel:0000';"/> </div>
When I go to example.com from mobile browser and click on button, it can launch Dialer app with phone number
When I click from webview it shows this error
Web page not available The web page at tel:0000 could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME
I do not know what is went wrong. Any clue will be helpfull.
NB: I am using real phone number (here it is 0000).
Thank you
You should set a WebViewClient to the WebView and than override shouldOverrideUrlLoading method as follow:
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (request.getUrl().toString().startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL, request.getUrl());
view.getContext().startActivity(intent);
}
return super.shouldOverrideUrlLoading(view, request);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.