Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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