Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save givemepassxd999/7c386eab6c60bc64fbe2af78672c2aa5 to your computer and use it in GitHub Desktop.
Save givemepassxd999/7c386eab6c60bc64fbe2af78672c2aa5 to your computer and use it in GitHub Desktop.
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("mailto:")) {
context.startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse(url)));
} else if(url.startsWith("http:")){
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
view.reload();
return true;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
final Uri uri = request.getUrl();
if (uri.toString().startsWith("mailto:")) {
//Handle mail Urls
context.startActivity(new Intent(Intent.ACTION_SENDTO, uri));
} else if(uri.toString().startsWith("http:")){
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri.toString())));
}
view.reload();
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment