Skip to content

Commit

Permalink
Merge pull request slymax#8 from hypothermic/master
Browse files Browse the repository at this point in the history
Fix NullPointerException in MyWebViewClient
  • Loading branch information
slymax authored Feb 16, 2019
2 parents 37ec256 + 811160c commit 1e48553
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 @@ -12,12 +12,13 @@ class MyWebViewClient extends WebViewClient {
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Objects.requireNonNull(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 1e48553

Please sign in to comment.