I have my WebView
loading all links inside the webview - but when I select an email link it tries to load it in the webview instead of launching an email app on the phone. How do I resolve that? the links are mailto://[email protected]
Here is my code - the WebView
itself works right and everything loads inside the webview, including mailto:, etc. Need the mailto links to load elsewhere
package com.apps.jerdog.crcc;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@SuppressWarnings("unused")
public class mainActivity extends Activity {
/** Called when the activity is first created. */
/**@Override */
WebView webview;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("http://www.cedarridge.cc");
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private class myWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if (url.startsWith("mailto:") || url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(intent);
}
view.loadUrl(url);
return true;
}
}}