Skip to content

Instantly share code, notes, and snippets.

@Debashis-Sinha
Created February 27, 2019 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Debashis-Sinha/6ce025801a4000687f19d7d276f24864 to your computer and use it in GitHub Desktop.
Save Debashis-Sinha/6ce025801a4000687f19d7d276f24864 to your computer and use it in GitHub Desktop.
Android open allowed link only
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment