Created
April 24, 2019 09:07
-
-
Save givemepassxd999/7c386eab6c60bc64fbe2af78672c2aa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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