Stay organized with collections
Save and categorize content based on your preferences.
SafeBrowsingResponse
abstract class SafeBrowsingResponse
Used to indicate an action to take when hitting a malicious URL. Instances of this class are created by the WebView and passed to android.webkit.WebViewClient#onSafeBrowsingHit
. The host application must call showInterstitial(boolean)
, proceed(boolean)
, or backToSafety(boolean)
to set the WebView's response to the Safe Browsing hit.
If reporting is enabled, all reports will be sent according to the privacy policy referenced by android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()
.
Summary
Public methods |
abstract Unit |
Act as if the user clicked the "back to safety" button.
|
abstract Unit |
Act as if the user clicked the "visit this unsafe site" button.
|
abstract Unit |
Display the default interstitial.
|
Public constructors
SafeBrowsingResponse
SafeBrowsingResponse()
Deprecated: This class should not be constructed by applications.
Public methods
backToSafety
abstract fun backToSafety(report: Boolean): Unit
Act as if the user clicked the "back to safety" button.
Parameters |
report |
Boolean: true to enable Safe Browsing reporting. |
proceed
abstract fun proceed(report: Boolean): Unit
Act as if the user clicked the "visit this unsafe site" button.
Parameters |
report |
Boolean: true to enable Safe Browsing reporting. |
showInterstitial
abstract fun showInterstitial(allowReporting: Boolean): Unit
Display the default interstitial.
Parameters |
allowReporting |
Boolean: true if the interstitial should show a reporting checkbox. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SafeBrowsingResponse\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSafeBrowsingResponse\n====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/webkit/SafeBrowsingResponse \"View this page in Java\") \n\n```\nabstract class SafeBrowsingResponse\n```\n\n|---|------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.webkit.SafeBrowsingResponse](#) |\n\nUsed to indicate an action to take when hitting a malicious URL. Instances of this class are created by the WebView and passed to [android.webkit.WebViewClient#onSafeBrowsingHit](/reference/kotlin/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20kotlin.Int,%20android.webkit.SafeBrowsingResponse)). The host application must call [showInterstitial(boolean)](#showInterstitial(kotlin.Boolean)), [proceed(boolean)](#proceed(kotlin.Boolean)), or [backToSafety(boolean)](#backToSafety(kotlin.Boolean)) to set the WebView's response to the Safe Browsing hit.\n\nIf reporting is enabled, all reports will be sent according to the privacy policy referenced by [android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()](/reference/kotlin/android/webkit/WebView#getSafeBrowsingPrivacyPolicyUrl()).\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------|---|\n| [SafeBrowsingResponse](#SafeBrowsingResponse())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [backToSafety](#backToSafety(kotlin.Boolean))`(`report:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Act as if the user clicked the \"back to safety\" button. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [proceed](#proceed(kotlin.Boolean))`(`report:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Act as if the user clicked the \"visit this unsafe site\" button. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [showInterstitial](#showInterstitial(kotlin.Boolean))`(`allowReporting:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Display the default interstitial. |\n\nPublic constructors\n-------------------\n\n### SafeBrowsingResponse\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nSafeBrowsingResponse()\n```\n\n**Deprecated:** *This class should not be constructed by applications.*\n\nPublic methods\n--------------\n\n### backToSafety\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun backToSafety(report: Boolean): Unit\n```\n\nAct as if the user clicked the \"back to safety\" button.\n\n| Parameters ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------|\n| `report` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable Safe Browsing reporting. |\n\n### proceed\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun proceed(report: Boolean): Unit\n```\n\nAct as if the user clicked the \"visit this unsafe site\" button.\n\n| Parameters ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------|\n| `report` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable Safe Browsing reporting. |\n\n### showInterstitial\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun showInterstitial(allowReporting: Boolean): Unit\n```\n\nDisplay the default interstitial.\n\n| Parameters ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `allowReporting` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if the interstitial should show a reporting checkbox. |"]]