Skip to content

Commit

Permalink
uri.getHost() can be null if the user clicks on mailto: links and pho…
Browse files Browse the repository at this point in the history
…ne numbers
  • Loading branch information
hypothermic committed Dec 22, 2018
1 parent 11dd578 commit 0fe0748
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/com/example/app/MyWebViewClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ public class MyWebViewClient extends WebViewClient {

@Override
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;
}

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
}
}

0 comments on commit 0fe0748

Please sign in to comment.