Created
August 19, 2020 18:58
-
-
Save fatihkurcenli/8c4bb64c2a286181ed7011c373e43e12 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
class MyWebViewClient : 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 fun onSafeBrowsingHit( | |
view: WebView, | |
request: WebResourceRequest, | |
threatType: Int, | |
callback: SafeBrowsingResponse | |
) { | |
// The "true" argument indicates that your app reports incidents like | |
// this one to Safe Browsing. | |
callback.backToSafety(true) | |
Toast.makeText(view.context, "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