File tree Expand file tree Collapse file tree
app/src/main/java/com/webview/myapplication Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -276,11 +276,26 @@ private class HelloWebViewClient extends WebViewClient {
276276 public boolean shouldOverrideUrlLoading (final WebView view , final String url ) {
277277 String host = Uri .parse (url ).getHost ();
278278 boolean isAllowed = false ;
279+
280+ if (url .startsWith ("tel:" )) {
281+ Intent tel = new Intent (Intent .ACTION_DIAL , Uri .parse (url ));
282+ startActivity (tel );
283+ return true ;
284+ }
285+
286+ if (url .contains ("mailto:" )){
287+ view .getContext ().startActivity (
288+ new Intent (Intent .ACTION_VIEW , Uri .parse (url )));
289+ }
290+
291+ if (host == null ) {
292+ isAllowed = true ; // mailto: links
293+ }
279294 if (!STARTUP_URL .isEmpty () && url .equals (STARTUP_URL )) {
280295 isAllowed = true ;
281296 }
282297 for (String domain : ALLOWED_DOMAINS ) {
283- if (host .equals (domain ) || host .equals ("www." + domain ) || host .equals ("m." + domain )) {
298+ if (host == null || host .equals (domain ) || host .equals ("www." + domain ) || host .equals ("m." + domain )) {
284299 isAllowed = true ;
285300 break ;
286301 }
You can’t perform that action at this time.
0 commit comments