BackForwardCacheSettings
@WebSettingsCompat.ExperimentalBackForwardCacheSettings
class BackForwardCacheSettings
A class for developers to configure the back-forward cache on a WebView.
The back-forward cache is a browser feature that improves the user experience by keeping pages alive for a limited time after the user navigates away from them. If the user navigates back or forward, the page is reused for a fast back navigation.
Example:
BackForwardCacheSettings settings = WebSettingsCompat.getBackForwardCacheSettings(webView.getSettings()); settings.setTimeoutSeconds(600); settings.setMaxPagesInCache(10);
Summary
Public functions |
|
|---|---|
@IntRange(from = 0) Int |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Returns the maximum number of pages that can be stored in the back-forward cache. |
@IntRange(from = 0) Long |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Returns the timeout for pages in the back-forward cache, in seconds. |
Boolean |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V4, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Returns whether to keep forward cache entries when the back-forward cache is enabled. |
Unit |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V4, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Sets whether to keep forward cache entries when the back-forward cache is enabled. |
Unit |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Sets the maximum number of pages that can be stored in the back-forward cache. |
Unit |
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Sets the timeout for pages in the back-forward cache. |
Public functions
getMaxPagesInCache
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
fun getMaxPagesInCache(): @IntRange(from = 0) Int
Returns the maximum number of pages that can be stored in the back-forward cache.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
getTimeoutSeconds
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
fun getTimeoutSeconds(): @IntRange(from = 0) Long
Returns the timeout for pages in the back-forward cache, in seconds.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
isKeepForwardEntriesEnabled
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V4, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@WebSettingsCompat.ExperimentalBackForwardCacheSettings
fun isKeepForwardEntriesEnabled(): Boolean
Returns whether to keep forward cache entries when the back-forward cache is enabled.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
setKeepForwardEntriesEnabled
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V4, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@WebSettingsCompat.ExperimentalBackForwardCacheSettings
fun setKeepForwardEntriesEnabled(keepForwardEntries: Boolean): Unit
Sets whether to keep forward cache entries when the back-forward cache is enabled.
| Parameters | |
|---|---|
keepForwardEntries: Boolean |
Whether to keep forward cache entries. |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
setMaxPagesInCache
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
fun setMaxPagesInCache(maxPagesInCache: @IntRange(from = 0) Int): Unit
Sets the maximum number of pages that can be stored in the back-forward cache.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
setTimeoutSeconds
@RequiresFeature(name = WebViewFeature.BACK_FORWARD_CACHE_SETTINGS_EXPERIMENTAL_V3, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
fun setTimeoutSeconds(timeoutSeconds: @IntRange(from = 0) Long): Unit
Sets the timeout for pages in the back-forward cache.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |