Created
August 19, 2020 18:59
-
-
Save fatihkurcenli/2118f5341f3f4f7d67200e2254613811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyWebViewClient extends WebViewClient { | |
// Automatically go "back to safety" when attempting to load a website that | |
// Safe Browsing has identified as a known threat. An instance of WebView | |
// calls this method only after Safe Browsing is initialized, so there's no | |
// conditional logic needed here. | |
@Override | |
public void onSafeBrowsingHit(WebView view, WebResourceRequest request, | |
int threatType, SafeBrowsingResponse callback) { | |
// The "true" argument indicates that your app reports incidents like | |
// this one to Safe Browsing. | |
callback.backToSafety(true); | |
Toast.makeText(view.getContext(), "Unsafe web page blocked.", | |
Toast.LENGTH_LONG).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment