Availability of Android WebView for detection and pop-up email or phone call dialogue

On android, when the built-in browser gets via email or phone number, and it is pressed, a dialog box appears for each.

However, if I go to this URL in my webview of the application, this is no longer the case.

In any case, the same properties as the browser application will be displayed for my web browser, when the emails and phone numbers are detected and when you click on them, the corresponding default dialogs appear?

I know that iPhone can do this with a checkbox in Interface Builder very easily, I hope that android can do the same.

I reviewed links such as:

Is there a way to have the urls and phone numbers of web pages in Android?

and using a function that interrupts the click of a link, but that doesn't really help me, because phone numbers and emails do not have to be connected.

+4
source share
4 answers

I was looking for the same problem as yours.

If you want to keep the URL contained in the web view, but enter the phone number beginning the dialer and the email address will start the mail client, try this.

Android WebView "tel:" links show webpage not found

The bottom solution worked for me.

+3
source

I installed WebView to detect my phone, email, and address (in which case it will appear on Google Maps). This is what I have:

URL = "file:///android_asset/dir/people.html"; webView = (WebView) findViewById(R.id.webViewDir); 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; } else if (url.startsWith("mailto:")) { url = url.substring(7); String body = "Body of message."; Intent mail = new Intent(Intent.ACTION_SEND); mail.setType("application/octet-stream"); mail.putExtra(Intent.EXTRA_EMAIL, new String[] { url }); mail.putExtra(Intent.EXTRA_SUBJECT, "Subject"); mail.putExtra(Intent.EXTRA_TEXT, body); startActivity(mail); return true; } else if (url.startsWith("map:")){ url = url.substring(4); String map = "http://maps.google.com/maps?q=" + url; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(map)); startActivity(intent); return true; } return false; } }); webView.loadUrl(URL); 
+2
source

This is for telephone, you can add another if by email :)

 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; } 
+1
source
  @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("mailto:")) { try { Intent emailIntent = new Intent(Intent.ACTION_SEND, Uri.parse(url)); emailIntent.setType("message/rfc822"); String recipient = url.substring( url.indexOf(":")+1 ); if (TextUtils.isEmpty(recipient)) recipient = " loco@wareninja.com "; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mContext.getString(R.string.email_subject)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mContext.getString(R.string.email_message, " ")); mContext.startActivity(Intent.createChooser(emailIntent, "Send mail...")); } catch (Exception ex) {} } return true; } 
0
source

All Articles