uri.getHost() can be null if the user clicks on mailto: links and phone numbers

This commit is contained in:
hypothermic 2018-12-22 21:19:11 +01:00
parent 11dd5784e5
commit 0fe0748d09

View File

@ -9,7 +9,8 @@ public class MyWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().endsWith("example.com")) { Uri uri = Uri.parse(url);
if (uri.getHost() != null && uri.getHost().contains("example.com")) {
return false; return false;
} }
@ -17,4 +18,4 @@ public class MyWebViewClient extends WebViewClient {
view.getContext().startActivity(intent); view.getContext().startActivity(intent);
return true; return true;
} }
} }