UltimateWebView2
ClientCertRequest
The user receives an instance of this class as a parameter of UltimateWebViewClient's ReceivedClientCertRequest event. The request includes the parameters to choose the client certificate, such as the host name and the port number requesting the cert, the acceptable key types and the principals names. The user should call one of the class methods to indicate how to deal with the client certificate request.
This class cannot be initialized by the user.
Functions:
- Cancel
Cancel this request. Remember the user's choice and use it for future requests.
- Ignore
Ignore the request for now. Do not remember user's choice.
- IsInitialized As Boolean
- Proceed
Proceed with certificate. Remember the user's positive choice and use it for future requests.
Properties:
- Host As String [read only]
Gets the host name of the server requesting the certificate.
- KeyTypes As String() [read only]
Gets the acceptable types of asymmetric keys.
- Port As Int [read only]
Gets the port number of the server requesting the certificate.
- PrincipalsNames As String() [read only]
Gets the acceptable certificate issuers names for the certificate matching the private key.
ConsoleMessage
Public class representing a JavaScript console message from WebCore. This could be a issued by a call to one of the console logging functions or a JavaScript error on the page. To receive notifications of these messages, override the UltimateWebChromeClient's ConsoleMessage event.
Fields:
- MESSAGE_LEVEL_DEBUG As Object
- MESSAGE_LEVEL_ERROR As Object
- MESSAGE_LEVEL_LOG As Object
- MESSAGE_LEVEL_TIP As Object
- MESSAGE_LEVEL_WARNING As Object
Functions:
- Initialize (Message As String, SourceId As String, LineNumber As Int, MessageLevel As Object)
- IsInitialized As Boolean
Properties:
- LineNumber As Int [read only]
- Message As String [read only]
- MessageLevel As Object [read only]
- SourceId As String [read only]
ConsoleMessage
This module contains only static methods and fields.
Fields:
- MESSAGE_LEVEL_DEBUG As Object
- MESSAGE_LEVEL_ERROR As Object
- MESSAGE_LEVEL_LOG As Object
- MESSAGE_LEVEL_TIP As Object
- MESSAGE_LEVEL_WARNING As Object
CookieManager
Manages the cookies used by an application's WebView instances.
CookieManager represents cookies as strings in the same format as the HTTP Cookie and Set-Cookie header fields (defined in RFC6265bis).
Functions:
- Flush
Ensures all cookies currently accessible through the getCookie API are written to persistent storage. This call will block the caller until it is done and may perform I/O.
Added in API level 21
- GetCookie (Url As String) As String
Gets all the cookies for the given URL. This may return multiple key-value pairs if multiple cookies are associated with this URL, in which case each cookie will be delimited by "; " characters (semicolon followed by a space). Each key-value pair will be of the form "key=value".
Url: the URL for which the cookies are requested
Returns value the cookies as a string, using the format of the 'Cookie' HTTP request header.
- GetCookieInfo (Url As String) As List
Gets all the cookies for the given URL along with their set attributes. The cookies are returned in the format of the HTTP 'Set-Cookie' header as defined in the RFC6265 spec. eg. "name=value; domain=.example.com; path=/"
Url: the URL for which the API retrieves all available cookies.
Returns the cookies as a List of strings.
Method implemented from webkit Compat package.
- HasCookies As Boolean
Gets whether there are stored cookies.
- Initialize (WebViewObject As Object)
Initializes new class instance.
If UltimateWebView is used, variable declaration and initialization of this class is not required. In that case, the cookies manager can be found in the UltimateWebView1.CookieManager property.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object.
- IsInitialized As Boolean
- RemoveAllCookies
Removes all cookies.
- RemoveExpiredCookie
Removes all expired cookies.
This method was deprecated in API level 21. The WebView handles removing expired cookies automatically.
- RemoveSessionCookies
Removes all session cookies, which are cookies without an expiration date.
- SetCookie (Url As String, Value As String)
Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired. To set multiple cookies, your application should invoke this method multiple times.
Url: the URL for which the cookie is to be set.
Value: the cookie as a string, using the format of the 'Set-Cookie' HTTP response header.
Properties:
- AcceptCookies As Boolean
Gets or sets whether the application's WebView instances should send and accept cookies. By default this is set to true and the WebView accepts cookies.
When this is true AcceptThirdPartyCookies and AcceptFileSchemeCookies can be used to control the policy for those specific types of cookie.
- AcceptFileSchemeCookies As Boolean
Gets or sets whether the application's WebView instances should send and accept cookies for file scheme URLs.
Deprecated in API level 30
- AcceptThirdPartyCookies As Boolean
Gets or sets whether the WebView should allow third party cookies to be set. Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances.
Apps that target Api level 20 or below default to allowing third party cookies. Apps targeting Api level 21 or later default to disallowing third party cookies.
Added in API level 21
DownloadProperties
This class is custom class and is not part of android.webkit package.
Fields:
- ContentDisposition As String
- ContentLength As Long
- Cookies As String
- DownloadID As Long
- FileExtension As String
- FileName As String
- MimeType As String
- Url As String
- UserAgent As String
FileChooserParams
Parameters used in the UltimateWebChromeClient's ShowFileChooser event.
This class cannot be initialized by the user.
Fields:
- MODE_OPEN As Int
Open single file. Requires that the file exists before allowing the user to pick it.
Added in API level 21
- MODE_OPEN_MULTIPLE As Int
Like Open but allows multiple files to be selected.
Added in API level 21
- MODE_SAVE As Int
Allows picking a nonexistent file and saving it.
Added in API level 21
Functions:
- IsInitialized As Boolean
- ParseResult (ResultCode As Int, Data As Intent) As Object
Parse the result returned by the file picker activity.
ResultCode: the integer result code returned by the file picker activity.
Data: the intent returned by the file picker activity.
Returns the array of Uri's as Object of selected file(s) or null if the resultCode indicates activity cancelled or any other error.
Properties:
- AcceptTypes As String() [read only]
Gets an array of acceptable MIME types. The returned MIME type could be partial such as audio/*. The array will be empty if no acceptable types are specified.
Added in API level 21
- FilenameHint As String [read only]
Gets the file name of a default selection if specified, or empty string.
Added in API level 21
- Intent As Intent [read only]
Gets an intent that would start a file picker for file selection. The Intent supports choosing files from simple file sources available on the device. Some advanced sources (for example, live media capture) may not be supported and applications wishing to support these sources or more advanced file operations should build their own Intent.
Added in API level 21
- IsCaptureEnabled As Boolean [read only]
Gets preference for a live media captured value (e.g. Camera, Microphone). True indicates capture is enabled, false disabled. Use AcceptTypes to determine suitable capture devices.
Added in API level 21
- Mode As Int [read only]
Gets file chooser mode.
Values: MODE_OPEN, MODE_OPEN_MULTIPLE or MODE_SAVE. Values can be found on FileChooserParams module (example: FileChooserParams.MODE_OPEN).
Added in API level 21
- Title As String [read only]
Gets the title to use for this file selector. If is an empty string a default title should be used.
Added in API level 21
FileChooserParams
This module contains only static methods and fields.
Fields:
- MODE_OPEN As Int
Open single file. Requires that the file exists before allowing the user to pick it.
Added in API level 21
- MODE_OPEN_MULTIPLE As Int
Like Open but allows multiple files to be selected.
Added in API level 21
- MODE_SAVE As Int
Allows picking a nonexistent file and saving it.
Added in API level 21
Functions:
- ParseResult (ResultCode As Int, Data As Intent) As Object
Parse the result returned by the file picker activity.
ResultCode: the integer result code returned by the file picker activity.
Data: the intent returned by the file picker activity.
Returns the array of Uri's as Object of selected file(s) or null if the resultCode indicates activity cancelled or any other error.
GeolocationPermission
This class is used to manage permissions for the WebView's Geolocation JavaScript API. Geolocation permissions are applied to an origin, which consists of the host, scheme and port of a URI. In order for web content to use the Geolocation API, permission must be granted for that content's origin. This class stores Geolocation permissions. An origin's permission state can be either allowed or denied. This class uses Strings to represent an origin. When an origin attempts to use the Geolocation API, but no permission state is currently set for that origin, UltimateWebChromeClient's GeolocationPermissionsRequest event is called. This allows the permission state to be set for that origin. The methods of this class can be used to modify and interrogate the stored Geolocation permissions at any time.
Events:
- GetOriginsResult (Origins As List)
- IsAllowedResult (Allowed As Boolean)
Functions:
- Allow (Origin As String)
Allows the specified origin to use the Geolocation API.
Origin: the origin for which Geolocation API use is allowed
- Clear (Origin As String)
Clears the Geolocation permission state for the specified origin.
Origin: the origin for which Geolocation permissions are cleared
- ClearAll
Clears the Geolocation permission state for all origins.
- GetOrigins
Gets the list of origins for which Geolocation permissions are stored.
This method is asynchronized. When result become available, event "GetOriginsResult" will be fired. Use WaitFor for synchronized result.
- Initialize (EventName As String)
- IsAllowed (Origin As String)
Gets the Geolocation permission state for the specified origin.
Origin: the origin for which Geolocation permission is requested
This method is asynchronized. When result become available, event "IsAllowedResult" will be fired. Use WaitFor for synchronized result.
- IsInitialized As Boolean
GeolocationPermissionCallback
A callback class used by the host application to set the Geolocation permission state for an origin.
This class cannot be initialized by the user.
Functions:
- Invoke (Origin As String, Allow As Boolean, Retain As Boolean)
Sets the Geolocation permission state for the supplied origin.
Origin: the origin for which permissions are set.
Allow: whether or not the origin should be allowed to use the Geolocation API.
Retain: whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView.
- IsInitialized As Boolean
HitTestResult
This class cannot be initialized by the user.
Fields:
- ANCHOR_TYPE As Int
Constant Value: 1
- EDIT_TEXT_TYPE As Int
HitTestResult for hitting an edit text area.
Constant Value: 9
- EMAIL_TYPE As Int
HitTestResult for hitting an email address.
Constant Value: 4
- GEO_TYPE As Int
HitTestResult for hitting a map address.
Constant Value: 3
- IMAGE_ANCHOR_TYPE As Int
Constant Value: 6
- IMAGE_TYPE As Int
HitTestResult for hitting an HTML::img tag.
Constant Value: 5
- PHONE_TYPE As Int
HitTestResult for hitting a phone number.
Constant Value: 2
- SRC_ANCHOR_TYPE As Int
HitTestResult for hitting a HTML::a tag with src=http.
Constant Value: 7
- SRC_IMAGE_ANCHOR_TYPE As Int
HitTestResult for hitting a HTML::a tag with src=http + HTML::img.
Constant Value: 8
- UNKNOWN_TYPE As Int
Default HitTestResult, where the target is unknown.
Constant Value: 0
Functions:
Properties:
- Extra As String [read only]
Gets additional type-dependant information about the result. May either be null or contain extra information about this result.
- Type As Int [read only]
Gets the type of the hit test result. See the XXX_TYPE constants defined in this class.
HitTestResult
This module contains only static methods and fields.
Fields:
- ANCHOR_TYPE As Int
Constant Value: 1
- EDIT_TEXT_TYPE As Int
HitTestResult for hitting an edit text area.
Constant Value: 9
- EMAIL_TYPE As Int
HitTestResult for hitting an email address.
Constant Value: 4
- GEO_TYPE As Int
HitTestResult for hitting a map address.
Constant Value: 3
- IMAGE_ANCHOR_TYPE As Int
Constant Value: 6
- IMAGE_TYPE As Int
HitTestResult for hitting an HTML::img tag.
Constant Value: 5
- PHONE_TYPE As Int
HitTestResult for hitting a phone number.
Constant Value: 2
- SRC_ANCHOR_TYPE As Int
HitTestResult for hitting a HTML::a tag with src=http.
Constant Value: 7
- SRC_IMAGE_ANCHOR_TYPE As Int
HitTestResult for hitting a HTML::a tag with src=http + HTML::img.
Constant Value: 8
- UNKNOWN_TYPE As Int
Default HitTestResult, where the target is unknown.
Constant Value: 0
HttpAuthHandler
Represents a request for HTTP authentication. Instances of this class are created by the WebView and passed to UltimateWebViewClient's ReceivedHttpAuthRequest event. The host application must call either Proceed or Cancel to set the WebView's response to the request.
This class cannot be initialized by the user.
Functions:
- Cancel
Instructs the WebView to cancel the authentication request.
- IsInitialized As Boolean
- Proceed (UserName As String, Password As String)
Instructs the WebView to proceed with the authentication with the given credentials.
- UseHttpAuthUsernamePassword As Boolean
Gets whether the credentials stored for the current host (i.e. the host for which UltimateWebViewClient's ReceivedHttpAuthRequest event was called) are suitable for use. Credentials are not suitable if they have previously been rejected by the server for the current request.
JsPromptResult
This class cannot be initialized by the user.
Functions:
- Cancel
Handle the result if the user cancelled the dialog.
- Confirm
Handle a confirmation response from the user.
- Confirm2 (Result As String)
Handle a confirmation response from the user.
- IsInitialized As Boolean
JsResult
This class cannot be initialized by the user.
Functions:
- Cancel
Handle the result if the user cancelled the dialog.
- Confirm
Handle a confirmation response from the user.
- IsInitialized As Boolean
MimeTypeMap
This module contains only static methods and fields.
Functions:
- GetExtensionFromMimeType (MimeType As String) As String
Return the registered extension for the given MIME type. Note that some MIME types map to multiple extensions. This call will return the most common extension for the given MIME type.
- GetFileExtensionFromUrl (Url As String) As String
Returns the file extension or an empty string if there is no extension. This method is a convenience method for obtaining the extension of a url and has undefined results for other Strings.
- GetMimeTypeFromExtension (Extension As String) As String
Return the MIME type for the given extension.
Extension: A file extension without the leading '.'
- HasExtension (Extension As String) As Boolean
Return True if the given extension has a registered MIME type.
Extension: A file extension without the leading '.'
- HasMimeType (MimeType As String) As Boolean
Return true if the given MIME type has an entry in the map.
PermissionRequest
This class cannot be initialized by the user.
Fields:
- RESOURCE_AUDIO_CAPTURE As String
Resource belongs to audio capture device, like microphone.
Constant Value: "android.webkit.resource.AUDIO_CAPTURE"
Added in API level 21
- RESOURCE_MIDI_SYSEX As String
Resource will allow sysex messages to be sent to or received from MIDI devices. These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above.
Constant Value: "android.webkit.resource.MIDI_SYSEX"
Added in API level 23
- RESOURCE_PROTECTED_MEDIA_ID As String
Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests.
Constant Value: "android.webkit.resource.PROTECTED_MEDIA_ID"
Added in API level 21
- RESOURCE_VIDEO_CAPTURE As String
Resource belongs to video capture device, like camera.
Constant Value: "android.webkit.resource.VIDEO_CAPTURE"
Added in API level 21
Functions:
- Deny
Call this method to deny the request.
Added in API level 21
- Grant (Resources As String())
Call this method to grant origin the permission to access the given resources. The granted permission is only valid for this WebView.
Resources: the resources granted to be accessed by origin, to grant request, the requested resources returned by Resources property must be equals or a subset of granted resources. This parameter is designed to avoid granting permission by accident especially when new resources are requested by web content.
- IsInitialized As Boolean
Properties:
- Origin As String [read only]
Gets the origin of the web page which is trying to access the restricted resources.
Added in API level 21
- OriginAsUri As Object [read only]
Gets the origin as Uri object of the web page which is trying to access the restricted resources.
Added in API level 21
- Resources As String() [read only]
Gets the resources the web page is trying to access.
Returns: RESOURCE_AUDIO_CAPTURE, RESOURCE_MIDI_SYSEX, RESOURCE_PROTECTED_MEDIA_ID or RESOURCE_VIDEO_CAPTURE.
Added in API level 21
PermissionRequest
This module contains only static methods and fields.
Fields:
- RESOURCE_AUDIO_CAPTURE As String
Resource belongs to audio capture device, like microphone.
Constant Value: "android.webkit.resource.AUDIO_CAPTURE"
Added in API level 21
- RESOURCE_MIDI_SYSEX As String
Resource will allow sysex messages to be sent to or received from MIDI devices. These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above.
Constant Value: "android.webkit.resource.MIDI_SYSEX"
Added in API level 23
- RESOURCE_PROTECTED_MEDIA_ID As String
Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests.
Constant Value: "android.webkit.resource.PROTECTED_MEDIA_ID"
Added in API level 21
- RESOURCE_VIDEO_CAPTURE As String
Resource belongs to video capture device, like camera.
Constant Value: "android.webkit.resource.VIDEO_CAPTURE"
Added in API level 21
SafeBrowsingResponse
This class cannot be initialized by the user.
Functions:
- BackToSafety (ParamBoolean As Boolean)
Act as if the user clicked the "back to safety" button.
ParamBoolean: true to enable Safe Browsing reporting.
Added in API level 27.
- IsInitialized As Boolean
- Proceed (ParamBoolean As Boolean)
Act as if the user clicked the "visit this unsafe site" button.
ParamBoolean: true to enable Safe Browsing reporting.
Added in API level 27.
- ShowInterstitial (ParamBoolean As Boolean)
Display the default interstitial.
ParamBoolean: true if the interstitial should show a reporting checkbox.
Added in API level 27.
SslError
This class represents a set of one or more SSL errors and the associated SSL certificate.
This class cannot be initialized by the user.
Fields:
- SSL_DATE_INVALID As Int
The date of the certificate is invalid
Constant Value: 4
- SSL_EXPIRED As Int
The certificate has expired.
Constant Value: 1
- SSL_IDMISMATCH As Int
Host name mismatch.
Constant Value: 2
- SSL_INVALID As Int
A generic error occurred.
Constant Value: 5
- SSL_NOTYETVALID As Int
The certificate is not yet valid.
Constant Value: 0
- SSL_UNTRUSTED As Int
The certificate authority is not trusted.
Constant Value: 3
Functions:
- HasError (Error As Int) As Boolean
Determines whether this object includes the supplied error.
Error: the SSL error to check for
Returns True if this object includes the error, otherwise false.
- IsInitialized As Boolean
Properties:
- Certificate As Object [read only]
Gets the SSL certificate as Object which is associated with this object.
- PrimaryError As Int [read only]
Gets the most severe SSL error in this object's set of errors. Returns -1 if the set is empty.
- Url As String [read only]
Gets the URL associated with this object.
SslError
This module contains only static methods and fields.
Fields:
- SSL_DATE_INVALID As Int
The date of the certificate is invalid
Constant Value: 4
- SSL_EXPIRED As Int
The certificate has expired.
Constant Value: 1
- SSL_IDMISMATCH As Int
Host name mismatch.
Constant Value: 2
- SSL_INVALID As Int
A generic error occurred.
Constant Value: 5
- SSL_NOTYETVALID As Int
The certificate is not yet valid.
Constant Value: 0
- SSL_UNTRUSTED As Int
The certificate authority is not trusted.
Constant Value: 3
SslErrorHandler
This class cannot be initialized by the user.
Functions:
- Cancel
Cancel this request and all pending requests for the WebView that had the error.
- IsInitialized As Boolean
- Proceed
Proceed with the SSL certificate.
It is not recommended to proceed past SSL errors and this method should generally not be used.
URLUtil
This module contains only static methods and fields.
Functions:
- ComposeSearchUrl (InQuery As String, Template As String, QueryPlaceHolder As String) As String
- Decode (Url As Byte()) As Byte()
- GuessFileName (Url As String, ContentDisposition As String, MimeType As String) As String
Guesses canonical filename that a download would have, using the URL and contentDisposition. File extension, if not defined, is added based on the mimetype.
Url: to the content
ContentDisposition: Content-Disposition HTTP header or null
MimeType: Mime-type of the content or null
- GuessUrl (InUrl As String) As String
Cleans up (if possible) user-entered web addresses
- IsAboutUrl (Url As String) As Boolean
Returns True if the url is an about: url.
- IsAssetUrl (Url As String) As Boolean
Returns True if the url is an asset: file.
- IsContentUrl (Url As String) As Boolean
Returns True if the url is a content: url.
- IsDataUrl (Url As String) As Boolean
Returns True if the url is a data: url.
- IsFileUrl (Url As String) As Boolean
Returns True if the url is an file: url.
- IsHttpsUrl (Url As String) As Boolean
Returns True if the url is an https: url.
- IsHttpUrl (Url As String) As Boolean
Returns True if the url is an http: url.
- IsJavaScriptUrl (Url As String) As Boolean
Returns True if the url is a javascript: url.
- IsNetworkUrl (Url As String) As Boolean
Returns True if the Url is a network url.
- IsValidUrl (Url As String) As Boolean
Returns True if the url is valid.
- StripAnchor (Url As String) As String
Strips the url of the anchor.
UltimateDownloadListener
This class is a customized version of DownloadListener and adapted to work in the B4A environment.
Events:
- FileDownloadCompleted (Success As Boolean, Properties As DownloadProperties) 'Works from API level 9 and above.
- FileDownloadInitialized (Properties As DownloadProperties) 'Works from API level 1 and above.
- FileDownloadStarted (Properties As DownloadProperties) 'Works from API level 9 and above.
Functions:
- ImplementInWebView (WebViewObject As Object) As UltimateDownloadListener
Implement this UltimateDownloadListener into WebView object.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateDownloadListener should be implemented.
Returns this UltimateDownloadListener.
- Initialize (EventName As String) As UltimateDownloadListener
Initializes new class instance. Use this method to initialize UltimateDownloadListener and later implement it in WebView manually.
EventName: to be used for events.
Returns initialized UltimateDownloadListener.
- Initialize2 (EventName As String, WebViewObject As Object) As UltimateDownloadListener
Initializes new class instance. Use this method to initialize and implement UltimateDownloadListener into a WebView object.
EventName: to be used for events.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateDownloadListener should be implemented.
Returns initialized UltimateDownloadListener.
- IsInitialized As Boolean
- RemoveFromWebView (WebViewObject As Object) As UltimateDownloadListener
Remove this UltimateDownloadListener or any other DownloadListener from a WebView object. Null will be set.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object from which UltimateDownloadListener should be removed.
Returns this UltimateDownloadListener.
- StartFileDownload (Properties As DownloadProperties, DownloadManagerTitle As String, DownloadManagerDescription As String, AllowScanningByMediaScanner As Boolean, DownloadManagerNotification As Boolean)
Use this method to start the file download. This method can only be used in the FileDownloadInitialized event. To download the file, the Android DownloadManager will be used and the downloaded file will be placed in the Download folder.
Properties: the DownloadProperties received from the FileDownloadInitialized event.
DownloadManagerTitle: Set the title of this download, to be displayed in notifications (if enabled). If Null or empty string is given, a default one will be assigned based on the download filename, once the download starts.
DownloadManagerDescription: Set a description of this download, to be displayed in notifications (if enabled).
AllowScanningByMediaScanner: scanning the file after the file download is complete. For API 29 and above it has no function because the system decides by itself.
DownloadManagerNotification: True to show DownloadManager in notifications bar. In case of False, it is necessary to copy next line in manifest:
AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
.
- StartFileDownload2 (Properties As DownloadProperties, Folder As String, DownloadManagerTitle As String, DownloadManagerDescription As String, AllowScanningByMediaScanner As Boolean, DownloadManagerNotification As Boolean)
Use this method to start the file download. This method can only be used in the FileDownloadInitialized event. To download the file, the Android DownloadManager will be used and the downloaded file will be placed in the specified Folder path with original file name.
Properties: the DownloadProperties received from the FileDownloadInitialized event.
Folder: where you want the downloaded file to be saved. From API 29 and above it is recommended to use RuntimePermission.GetSafeDirDefaultExternal (FileProvider.SharedFolder will throw exception). For API below 29 you must request "WRITE_EXTERNAL_STORAGE" permission. This value can not be Null or empty string.
DownloadManagerTitle: Set the title of this download, to be displayed in notifications (if enabled). If Null or empty string is given, a default one will be assigned based on the download filename, once the download starts.
DownloadManagerDescription: Set a description of this download, to be displayed in notifications (if enabled).
AllowScanningByMediaScanner: scanning the file after the file download is complete. For API 29 and above it has no function because the system decides by itself.
DownloadManagerNotification: True to show DownloadManager in notifications bar. In case of False, it is necessary to copy next line in manifest:
AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
.
- StartFileDownload3 (Properties As DownloadProperties, Folder As String, FileName As String, DownloadManagerTitle As String, DownloadManagerDescription As String, AllowScanningByMediaScanner As Boolean, DownloadManagerNotification As Boolean)
Use this method to start the file download. This method can only be used in the FileDownloadInitialized event. To download the file, the Android DownloadManager will be used and the downloaded file will be placed in the specified Folder with specified FileName.
Properties: the DownloadProperties received from the FileDownloadInitialized event.
Folder: where you want the downloaded file to be saved. From API 29 and above it is recommended to use RuntimePermission.GetSafeDirDefaultExternal (FileProvider.SharedFolder will throw exception). For API below 29 you must request "WRITE_EXTERNAL_STORAGE" permission. This value can not be Null or empty string.
FileName: the desired name of the downloaded file after the download is complete. This value can not be Null or empty string.
DownloadManagerTitle: Set the title of this download, to be displayed in notifications (if enabled). If Null or empty string is given, a default one will be assigned based on the download filename, once the download starts.
DownloadManagerDescription: Set a description of this download, to be displayed in notifications (if enabled).
AllowScanningByMediaScanner: scanning the file after the file download is complete. For API 29 and above it has no function because the system decides by itself.
DownloadManagerNotification: True to show DownloadManager in notifications bar. In case of False, it is necessary to copy next line in manifest:
AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
.
UltimateJavascriptInterface
This class is a customized version of JavascriptInterface and adapted to work in the B4A environment.
Associated JavascriptInterface methods:
ShowToast(String message, boolean lengthLong)
Log(String logMessage)
CallSub(String SubName, boolean CallUIThread)
CallSub(String SubName, boolean CallUIThread, String parameter1)
CallSub(String SubName, boolean CallUIThread, String parameter1, String parameter2)
CallSub(String SubName, boolean CallUIThread, String parameter1, String parameter2, String parameter3)
CallSub(String SubName, boolean CallUIThread, String parameter1, String parameter2, String parameter3, String parameter4)
Functions:
- Initialize
Initializes new class instance.
- IsInitialized As Boolean
UltimateWebChromeClient
This class is a customized version of WebChromeClient and adapted to work in the B4A environment.
Events:
- ConsoleMessage (Message As ConsoleMessage) As Boolean 'Works from API level 8 and above.
- CreateWindow (OverridenRequest As WebResourceRequest, ChildWebView As WebView, IsDialog As Boolean, IsUserGesture As Boolean) As Boolean 'Works from API level 1 and above. Return True if you want to consume ChildWebView, False to destroy. SupportMultipleWindows option must be enabled. You can add the newly created WebViewObject to Layout manualy, or use UltimateWebView's AddChildWindow method.
- GeolocationPermissionRequest (Origin As String, Callback As GeolocationPermissionCallback) 'Works from API level 5 and above.
- GeolocationPermissionRequestCanceled 'Works from API level 5 and above.
- JsAlert (Url As String, Message As String, Result As JsResult) As Boolean 'Works from API level 1 and above. Return true if the request is handled or ignored, false if WebView needs to show the default dialog.
- JsBeforeUnload (Url As String, Message As String, Result As JsResult) As Boolean 'Works from API level 1 and above. Return true if the request is handled or ignored, false if WebView needs to show the default dialog.
- JsConfirm (Url As String, Message As String, Result As JsResult) As Boolean 'Works from API level 1 and above. Return true if the request is handled or ignored, false if WebView needs to show the default dialog.
- JsPrompt (Url As String, Message As String, DefaultValue As String, Result As JsPromptResult) As Boolean 'Works from API level 1 and above. Return true if the request is handled or ignored, false if WebView needs to show the default dialog.
- PermissionsRequest (RequestedRuntimePermissions As List, Request As PermissionRequest) 'Works from API level 21 and above.
- PermissionsRequestCanceled (Request As PermissionRequest) 'Works from API level 21 and above.
- ProgressChanged (NewProgress As Int) 'Works from API level 1 and above.
- ReceivedIcon (Icon As Bitmap) 'Works from API level 1 and above.
- ReceivedTitle (Title As String) 'Works from API level 1 and above.
- ReceivedTouchIconUrl (Url As String, Precomposed As Boolean) 'Works from API level 7 and above.
- RequestFocus 'Works from API level 1 and above.
- ShowFileChooser (FilePathCallback As ValueCallbackUri, Params As FileChooserParams) 'Works from API level 21 and above. FilePathCallback.OnReceiveValue must be executed with value from file chooser, or null to abort.
Functions:
- AllowFullScreenVideo (Allowed As Boolean, ForceLandscape As Boolean) As UltimateWebChromeClient
This method enables or disables WebView's ability to play online video in full screen.
Allowed: True to allow, otherwise False. Default value is False
ForceLandscape: True to force full screen video to play in landscape screen orientation. Default value is False.
IMPORTANT: SoftOrientation library or other methods are required to prevent the Activity to redraw on the orientation change!!!
Returns this UltimateWebChromeClient.
- ImplementInWebView (WebViewObject As Object) As UltimateWebChromeClient
Implement this UltimateWebChromeClient into WebView object.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateWebChromeClient should be implemented.
Returns this UltimateWebChromeClient.
- Initialize (EventName As String) As UltimateWebChromeClient
Initializes new class instance. Use this method to initialize UltimateWebChromeClient and later implement it in WebView manually.
EventName: to be used for events.
Returns initialized UltimateWebChromeClient.
- Initialize2 (EventName As String, WebViewObject As Object) As UltimateWebChromeClient
Initializes new class instance. Use this method to initialize and implement UltimateWebChromeClient into a WebView object.
EventName: to be used for events.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateWebChromeClient should be implemented.
Returns initialized UltimateWebChromeClient.
- IsInitialized As Boolean
- RemoveFromWebView (WebViewObject As Object) As UltimateWebChromeClient
Remove this UltimateWebChromeClient or any other WebChromeClient from a WebView object. Null will be set.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object from which UltimateWebChromeClient should be removed.
Returns this UltimateWebChromeClient.
- ShowDefaultAppChooser (FilePathCallback As ValueCallbackUri, FileChooserParams As FileChooserParams, ForceCaptureEnabled As Boolean, FileProvidersSharedFolder As String)
Call this method after ShowFileChooser event is fired. This method will launch an application chooser which contains applications that meets the criteria for uploading the requested file or multiple files.
FilePathCallback: pass FilePathCallback received from ShowFileChooser event.
FileChooserParams: pass FileChooserParams received from ShowFileChooser event.
ForceCaptureEnabled: to True, an option for the camera will be offered as the file upload source (if web source request image, video or all file types). To False, value of IsCaptureEnabled from FileChooserParams will be used to determine if camera option is available (in most cases is not available).
FileProvidersSharedFolder: Default or custom FileProvider library is required. FileProvider's shared folder is necessary for temporary saving pictures and videos from the Camera which will be uploaded to the desired web service (file upload directly from the camera). If you pass Null or an empty string, Camera app will not be offered in application chooser for file upload.
If you pass ForceCaptureEnabled as True or if FileChooserParams.IsCaptureEnabled is True, and you have added permissions for CAMERA or RECORD_AUDIO in manifest, you must request them with RuntimePermissions before you call this method.
UltimateWebView
Events:
- Click
- EvaluateJavascriptResult (Result As String) 'Works from API level 19 and above. JavascriptEnabled must be True.
- FindResultReceived (ActiveMatchOrdinal As Int, NumberOfMatches As Int, IsDoneCounting As Boolean)
- FocusChange (Focused As Boolean)
- KeyPressed (KeyCode As Int, KeyEvent As Object) As Boolean
- LayoutChange (Left As Int, Top As Int, Width As Int, Height As Int, OldLeft As Int, OldTop As Int, OldWidth As Int, OldHeight As Int)
- LongClick As Boolean
- ScrollChange (ScrollX As Int, ScrollY As Int, OldScrollX As Int, OldScrollY As Int)
- Touch As Boolean
Fields:
- OVER_SCROLL_ALWAYS As Int
Always allow a user to over-scroll this view, provided it is a view that can scroll.
Constant Value: 0
- OVER_SCROLL_IF_CONTENT_SCROLLS As Int
Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.
Constant Value: 1
- OVER_SCROLL_NEVER As Int
Never allow a user to over-scroll this view.
Constant Value: 2
- RENDERER_PRIORITY_BOUND As Int
The renderer associated with this WebView is bound with the default priority for services.
Constant Value: 1
Added in API level 26
- RENDERER_PRIORITY_IMPORTANT As Int
The renderer associated with this WebView is bound with Context.BIND_IMPORTANT.
Constant Value: 2
Added in API level 26
- RENDERER_PRIORITY_WAIVED As Int
The renderer associated with this WebView is bound with Context.BIND_WAIVE_PRIORITY. At this priority level WebView renderers will be strong targets for out of memory killing.
Constant Value: 0
Added in API level 26
- SCROLLBARS_INSIDE_INSET As Int
The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. The scrollbars will not overlap the content area of the view.
Constant Value: 16777216
- SCROLLBARS_INSIDE_OVERLAY As Int
The scrollbar style to display the scrollbars inside the content area, without increasing the padding. The scrollbars will be overlaid with translucency on the view's content.
Constant Value: 0
- SCROLLBARS_OUTSIDE_INSET As Int
The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. The scrollbars will only overlap the background, if any.
Constant Value: 50331648
- SCROLLBARS_OUTSIDE_OVERLAY As Int
The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. The scrollbars will be overlaid with translucency.
Constant Value: 33554432
Functions:
- AddChildWindow (ChildWebViewObject As Object, IsDialog As Boolean)
Use this method to add child WebView object to UltimateWebView. Once added, UltimateWebView will handle this child WebView. This child WebView will be destroyed when user call GoBack and child cannot go back.
You can use this method when WebkiWebChromeClient's event "CreateWindow" has been fired.
ChildWebViewObject: native B4A WebView or some other custom WebView (UltimateWebView). Must not be Null or not initialized object.
IsDialog: pass true if the new window should be a dialog size, rather than a full-size window.
- AddJavascriptInterface (JavascriptInterface As Object, Name As String)
Injects the supplied JavascriptInterface As Object into this UltimateWebView. The object is injected into all frames of the web page, including all the iframes, using the supplied name. This allows the Java object's methods to be accessed from JavaScript.
- BringToFront
- CanGoBack As Boolean
Gets whether this WebView has a back history item.
- CanGoBackOrForward (Steps As Int) As Boolean
Gets whether the page can go back or forward the given number of steps.
Steps: the negative or positive number of steps to move the history
- CanGoForward As Boolean
Gets whether this WebView has a forward history item.
- ClearAnimation
- ClearCache (IncludeDiskFiles As Boolean)
Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used.
IncludeDiskFiles: if false, only the RAM cache is cleared.
- ClearFocus
- ClearFormData
Removes the autocomplete popup from the currently focused form field, if present. Note this only affects the display of the autocomplete popup, it does not remove any saved form data from this WebView's store.
- ClearHistory
Tells this WebView to clear its internal back/forward list.
- ClearMatches
Clears the highlighting surrounding text matches created by FindAllAsync method.
- ClearSslPreferences
Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
- ComputeScroll
- CreatePrintDocumentAdapter (DocumentName As String) As Object
Creates a PrintDocumentAdapter as Object that provides the content of this WebView for printing. The adapter works by converting the WebView contents to a PDF stream.
DocumentName: the user-facing name of the printed document. Cannot be null
For API levels 19 and 20, the DocumentName has no function and will not be used.
Added in API level 19
- DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
- Destroy
Destroys the internal state of this WebView. This method should be called after this WebView has been removed from the view system. No other methods may be called on this WebView after destroy.
- EnableSlowWholeDocumentDraw
For apps targeting the L release, UltimateWebView has a new default behavior that reduces memory footprint and increases performance by intelligently choosing the portion of the HTML document that needs to be drawn. These optimizations are transparent to the developers.
Added in API level 21
- EvaluateJavascript (JavaScriptString As String)
Evaluate Javascript in UltimateWebView and got asynchronius backward Result.
Event "EvaluateJavascriptResult (Result as String)" will be fired when result is available. Result can be "null".
JavaScriptString: the JavaScript to execute. This value cannot be Null or empty string.
Added in API level 19
Important: UltimateWebView1.Settings.JavaScriptEnabled = True. Must be set to True somewhere in code
- FindAllAsync (Find As String)
Finds all instances of find on the page and highlights them, asynchronously. Event "FindResultReceived" will be fired at process end. Successive calls to this will cancel any pending searches.
Find: the string to find. This value cannot be Null.
- FindNext (Forward As Boolean)
Highlights and scrolls to the next match found by FindAllAsync(Find As String), wrapping around page boundaries as necessary.
- FlingScroll (X As Int, Y As Int)
- GoBack
Goes back in the history of this WebView.
- GoBackOrForward (Steps As Int)
Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
- GoForward
Goes forward in the history of this WebView.
- HasFocus As Boolean
- Initialize (EventName As String)
- Initialize2 (EventName As String, B4AWebView As WebView)
- Invalidate
- Invalidate2 (mDrawable As android.graphics.drawable.Drawable)
- InvalidateOutline
- InvokeZoomPicker
Invokes the graphical zoom picker widget for this WebView. This will result in the zoom widget appearing on the screen to control the zoom level of this WebView.
- IsFocused As Boolean
- IsInitialized As Boolean
- LoadData (Data As String, MimeType As String, Encoding As String)
Loads the given data into this WebView using a 'data' scheme URL.
Note that JavaScript's same origin policy means that script running in a page loaded using this method will be unable to access content loaded using any scheme other than 'data', including 'http(s)'. To avoid this restriction, use LoadDataWithBaseURL with an appropriate base URL.
The encoding parameter specifies whether the data is base64 or URL encoded. If the data is base64 encoded, the value of the encoding parameter must be "base64".
Data: a String of data in the given encoding This value cannot be null.
MimeType: the MIME type of the data, e.g. 'text/html'. This value may be null.
Encoding: the encoding of the data This value may be null.
- LoadDataWithBaseURL (BaseUrl As String, Data As String, MimeType As String, Encoding As String, HistoryUrl As String)
Loads the given data into this WebView.
BaseUrl: the URL to use as the page's base URL. If null defaults to 'about:blank'.
Data: a String of data in the given encoding This value cannot be null.
MimeType: the MIME type of the data, e.g. 'text/html'. This value may be null.
Encoding: the encoding of the data This value may be null.
HistoryUrl: the URL to use as the history entry. If null defaults to 'about:blank'. If non-null, this must be a valid URL.
- LoadHTMLString (HTMLString As String)
Use this method to load HTML string into WebView.
- LoadUrl (Url As String)
Loads the given URL.
- LoadUrl2 (Url As String, AdditionalHttpHeaders As Map)
Loads the given URL with additional HTTP headers, specified as a map from name to value. Note that if this map contains any of the headers that are set by default by this WebView, such as those controlling caching, accept types or the User-Agent, their values may be overridden by this WebView's defaults.
Url: the URL of the resource to load This value cannot be null.
AdditionalHttpHeaders: map with additional headers This value cannot be null.
- PageDown (Bottom As Boolean) As Boolean
Scrolls the contents of this WebView down by half the page size.
Bottom: True to jump to bottom of page
Returns True if the page was scrolled.
- PageUp (Top As Boolean) As Boolean
Scrolls the contents of this WebView up by half the view size.
Top: True to jump to the top of the page
Returns True if the page was scrolled.
- Pause
Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. To pause JavaScript globally, use PauseTimers. To resume WebView, call Resume.
- PauseTimers
Pauses all layout, parsing, and JavaScript timers for all WebViews. This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused.
- PostUrl (Url As String, PostData As Byte())
Loads the URL with postData using "POST" method into this WebView. If url is not a network URL, it will be loaded with LoadUrl instead, ignoring the PostData param.
Url: the URL of the resource to load This value cannot be null.
PostData: the data will be passed to "POST" request, which must be be "application/x-www-form-urlencoded" encoded. This value cannot be null.
- Print (DocumentName As String)
This method is used to print actual WebView content.
DocumentName: name of document to be displayed.
- Reload
Reloads the current URL.
- RemoveJavascriptInterface (Name As String)
Removes a previously injected Javascript object from this WebView. Note that the removal will not be reflected in JavaScript until the page is next (re)loaded.
Name: the name used to expose the object in JavaScript. This value cannot be Null.
- RemoveView
Removes this view from its parent.
- RequestFocus As Boolean
Tries to set the focus to this view.
Returns True if the focus was set.
- Resume
Resumes a WebView after a previous call to Pause.
- ResumeTimers
Resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers previously paused with PauseTimers.
- SaveWebArchive (Filename As String)
Saves the current view as a web archive.
Filename: the filename where the archive should be placed This value cannot be null.
- SendToBack
Changes the Z order of this view and sends it to the back.
- SetBackgroundImage (Image As Bitmap)
- SetLayout (Left As Int, Top As Int, Width As Int, Height As Int)
Changes the view position and size.
- SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int)
Similar to SetLayout. Animates the change. Note that the animation will only be applied when running on Android 3+ devices.
Duration - Animation duration measured in milliseconds.
- SetPadding (Left As Int, Top As Int, Right As Int, Bottom As Int)
- SetRendererPriorityPolicy (RendererRequestedPriority As Int, WaivedWhenNotVisible As Boolean)
Set the renderer priority policy for this WebView. The priority policy will be used to determine whether an out of process renderer should be considered to be a target for OOM killing. Because a renderer can be associated with more than one WebView, the final priority it is computed as the maximum of any attached WebViews. When a WebView is destroyed it will cease to be considerered when calculating the renderer priority. Once no WebViews remain associated with the renderer, the priority of the renderer will be reduced to RENDERER_PRIORITY_WAIVED. The default policy is to set the priority to RENDERER_PRIORITY_IMPORTANT regardless of visibility, and this should not be changed unless the caller also handles renderer crashes. Any other setting will result in WebView renderers being killed by the system more aggressively than the application.
RendererRequestedPriority: the minimum priority at which this WebView desires the renderer process to be bound. Value is RENDERER_PRIORITY_WAIVED, RENDERER_PRIORITY_BOUND, or RENDERER_PRIORITY_IMPORTANT.
WaivedWhenNotVisible: if true, this flag specifies that when this WebView is not visible, it will be treated as if it had requested a priority of RENDERER_PRIORITY_WAIVED.
Added in API level 26
- SetVisibleAnimated (Duration As Int, Visible As Boolean)
Changes the view visibility with a fade-in or fade-out animation.
You must
Note that the animation will only be applied when running on Android 3+ devices.
Duration - Animation duration measured in milliseconds.
Visible - New visibility state.
- StopLoading
Stops the current load.
- ZoomBy (ZoomFactor As Float)
Performs a zoom operation in this WebView.
ZoomFactor: the zoom factor to apply. The zoom factor will be clamped to the WebView's zoom limits. This value must be in the range 0.01 to 100.0 inclusive.
- ZoomIn As Boolean
Performs zoom in in this WebView.
Returns true if zoom in succeeds, false if no zoom changes.
- ZoomOut As Boolean
Performs zoom out in this WebView.
Returns true if zoom out succeeds, false if no zoom changes.
Properties:
- Alpha As Float
- BackForwardList As WebBackForwardList [read only]
Gets the WebBackForwardList for this WebView. This contains the back/forward list for use in querying each item in the history stack.
- Background As android.graphics.drawable.Drawable
- Bottom As Int
- Certificate As Object [read only]
Gets the SSL certificate as Object for the main top-level page or null if there is no certificate (the site is not secure).
- Color As Int [write only]
- ContentHeight As Int [read only]
Gets the height of the HTML content.
- CookieManager As CookieManager [read only]
- DownloadListener As Object
Gets or sets the DownloadListener.
Set Null to remove DownloadListener
- Enabled As Boolean
- Favicon As Bitmap [read only]
Gets the favicon for the current page. This is the favicon of the current page until IGWebViewClient's "ReceivedIcon" event is called.
- Foreground As android.graphics.drawable.Drawable
- Height As Int
- HitTestResult As HitTestResult [read only]
Gets a HitTestResult based on the current cursor node. If a HTML::a tag is found and the anchor has a non-JavaScript URL, the HitTestResult type is set to SRC_ANCHOR_TYPE and the URL is set in the "extra" field. If the anchor does not have a URL or if it is a JavaScript URL, the type will be UNKNOWN_TYPE and the URL has to be retrieved through requestFocusNodeHref(Message) asynchronously. If a HTML::img tag is found, the HitTestResult type is set to IMAGE_TYPE and the URL is set in the "extra" field. A type of SRC_IMAGE_ANCHOR_TYPE indicates an anchor with a URL that has an image as a child node. If a phone number is found, the HitTestResult type is set to PHONE_TYPE and the phone number is set in the "extra" field of HitTestResult. If a map address is found, the HitTestResult type is set to GEO_TYPE and the address is set in the "extra" field of HitTestResult. If an email address is found, the HitTestResult type is set to EMAIL_TYPE and the email is set in the "extra" field of HitTestResult. Otherwise, HitTestResult type is set to UNKNOWN_TYPE.
- ID As Int
- InitialScale As Int [write only]
Sets the initial scale for this WebView. 0 means default.
- IsPrivateBrowsingEnabled As Boolean [read only]
Gets whether private browsing is enabled in this WebView.
- KeepScreenOn As Boolean
- Left As Int
- NetworkAvailable As Boolean [write only]
Informs WebView of the network state.
- OriginalUrl As String [read only]
Gets the original URL for the current page. This is not always the same as the URL passed to WebViewClient's PageStarted event because although the load for that URL has begun, the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested.
- OverScrollMode As Int
Gets or sets the over-scroll mode for this WebView. Valid over-scroll modes are OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the WebView content is larger than the container), or OVER_SCROLL_NEVER. Setting the over-scroll mode of a WebView will have an effect only if the view is capable of scrolling.
- PaddingBottom As Int [read only]
- PaddingLeft As Int [read only]
- PaddingRight As Int [read only]
- PaddingTop As Int [read only]
- Parent As Object [read only]
- Progress As Int [read only]
Gets the progress for the current page.
- RendererPriorityWaivedWhenNotVisible As Boolean [read only]
Gets whether this WebView requests a priority of RENDERER_PRIORITY_WAIVED when not visible.
Added in API level 26
- RendererRequestedPriority As Int [read only]
Get the requested renderer priority for this WebView.
Value is RENDERER_PRIORITY_WAIVED, RENDERER_PRIORITY_BOUND, or RENDERER_PRIORITY_IMPORTANT.
Added in API level 26
- Right As Int
- RootView As android.view.View [read only]
- SafeBrowsingPrivacyPolicyUrl As Object [read only]
Gets a URL pointing to the privacy policy for Safe Browsing reporting.
Added in API level 27
- ScrollBarStyle As Int
Gets or sets the style of the scrollbars.
- Settings As WebSettings [read only]
- Tag As Object
- Title As String [read only]
Gets the title for the current page. This is the title of the current page until WebViewClient ReceivedTitle event is called.
- Top As Int
- Url As String [read only]
Gets the URL for the current page. This is not always the same as the URL passed to WebViewClient PageStarted event because although the load for that URL has begun, the current page may not have changed. Null if no page has been loaded
- Visible As Boolean
- WebChromeClient As Object
Gets or sets the chrome handler.
Set Null to remove chrome handler
- WebViewClient As Object
Gets or sets the WebViewClient.
Set Null any time you want to return to default android's WebViewClient.
- WebViewDatabase As WebViewDatabase [read only]
- Width As Int
UltimateWebViewClient
This class is a customized version of WebViewClient and adapted to work in the B4A environment.
Events:
- LoadResource (Url As String) 'Works from API level 1 and above.
- OverrideUrl (Request As WebResourceRequest) As Boolean 'Works from API level 1 and above.
- PageCommitVisible (Url As String) 'Works from API level 23 and above.
- PageFinished (Url As String) 'Works from API level 1 and above.
- PageStarted (Url As String, FavIcon As Bitmap) 'Works from API level 1 and above.
- ReceivedClientCertRequest (Request As ClientCertRequest) 'Works from API level 21 and above.
- ReceivedError (ErrorCode As Int, Description As String, FailingRequest As WebResourceRequest) 'Works from API level 1 and above. From Api level 1 to 23, passed WebResourceRequest contains only Url.
- ReceivedHttpAuthRequest (Handler As HttpAuthHandler, Host As String, Realm As String) 'Works from API level 1 and above.
- ReceivedHttpError (Request As WebResourceRequest, Response As WebResourceResponse) 'Works from API level 23 and above.
- ReceivedLoginRequest (Realm As String, Account As String, Args As String) 'Works from API level 12 and above.
- ReceivedSslError (Handler As SslErrorHandler, Error As SslError) 'Works from API level 8 and above.
- RenderProcessGone (DidCrash As Boolean, RendererPriorityAtExit As Int) As Boolean 'Works from API level 26 and above.
- SafeBrowsingHit (Request As WebResourceRequest, SafeBrowsingThreatType As Int, Response As SafeBrowsingResponse) 'Works from API level 27 and above.
- ScaleChanged (OldScale As Float, NewScale As Float) 'Works from API level 1 and above.
- ShouldInterceptRequest (Request As WebResourceRequest) As WebResourceResponse 'Works from API level 11 and above. From Api level 11 to 20, passed WebResourceRequest contains only Url.
- ShouldOverrideKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) As Boolean 'Works from API level 1 and above.
- UnhandledKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) 'Works from API level 1 to API level 21.
- UpdateVisitedHistory (Url As String, IsReload As Boolean) 'Works from API level 1 and above.
Fields:
- ERROR_AUTHENTICATION As Int
User authentication failed on server.
Constant Value: -4
- ERROR_BAD_URL As Int
Malformed URL.
Constant Value: -12
- ERROR_CONNECT As Int
Failed to connect to the server.
Constant Value: -6
- ERROR_FAILED_SSL_HANDSHAKE As Int
Failed to perform SSL handshake.
Constant Value: -11
- ERROR_FILE As Int
Generic file error.
Constant Value: -13
- ERROR_FILE_NOT_FOUND As Int
File not found.
Constant Value: -14
- ERROR_HOST_LOOKUP As Int
Server or proxy hostname lookup failed.
Constant Value: -2
- ERROR_IO As Int
Failed to read or write to the server.
Constant Value: -7
- ERROR_PROXY_AUTHENTICATION As Int
User authentication failed on proxy.
Constant Value: -5
- ERROR_REDIRECT_LOOP As Int
Too many redirects.
Constant Value: -9
- ERROR_TIMEOUT As Int
Connection timed out.
Constant Value: -8
- ERROR_TOO_MANY_REQUESTS As Int
Too many requests during this load.
Constant Value: -15
- ERROR_UNKNOWN As Int
Generic error.
Constant Value: -1
- ERROR_UNSAFE_RESOURCE As Int
Resource load was canceled by Safe Browsing.
Constant Value: -16
Added in API level 26
- ERROR_UNSUPPORTED_AUTH_SCHEME As Int
Unsupported authentication scheme (not basic or digest).
Constant Value: -3
- ERROR_UNSUPPORTED_SCHEME As Int
Unsupported URI scheme.
Constant Value: -10
- SAFE_BROWSING_THREAT_BILLING As Int
The resource was blocked because it may trick the user into a billing agreement.
This constant is only used when targetSdkVersion is at least Build.VERSION_CODES.Q. Otherwise, SAFE_BROWSING_THREAT_UNKNOWN is used instead.
Constant Value: 4
Added in API level 29
- SAFE_BROWSING_THREAT_MALWARE As Int
The resource was blocked because it contains malware.
Constant Value: 1
Added in API level 27
- SAFE_BROWSING_THREAT_PHISHING As Int
The resource was blocked because it contains deceptive content.
Constant Value: 2
Added in API level 27
- SAFE_BROWSING_THREAT_UNKNOWN As Int
The resource was blocked for an unknown reason.
Constant Value: 0
Added in API level 27
- SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE As Int
The resource was blocked because it contains unwanted software.
Constant Value: 3
Added in API level 27
Functions:
- ImplementInWebView (WebViewObject As Object) As UltimateWebViewClient
Implement this UltimateWebViewClient into WebView object.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateWebViewClient should be implemented.
Returns this UltimateWebViewClient.
- Initialize (EventName As String) As UltimateWebViewClient
Initializes new class instance. Use this method to initialize UltimateWebViewClient and later implement it in WebView manually.
EventName: to be used for events.
Returns initialized UltimateWebViewClient.
- Initialize2 (EventName As String, WebViewObject As Object) As UltimateWebViewClient
Initializes new class instance. Use this method to initialize and implement UltimateWebViewClient into a WebView object.
EventName: to be used for events.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object in which UltimateWebViewClient should be implemented.
Returns initialized UltimateWebViewClient.
- IsInitialized As Boolean
- RemoveFromWebView (WebViewObject As Object) As UltimateWebViewClient
Remove this UltimateWebViewClient or any other WebViewClient from a WebView object. Default webkit's WebViewClient will be set.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object from which UltimateWebViewClient should be removed.
Returns this UltimateWebViewClient.
UltimateWebViewClient
This module contains only static methods and fields.
Fields:
- ERROR_AUTHENTICATION As Int
User authentication failed on server.
Constant Value: -4
- ERROR_BAD_URL As Int
Malformed URL.
Constant Value: -12
- ERROR_CONNECT As Int
Failed to connect to the server.
Constant Value: -6
- ERROR_FAILED_SSL_HANDSHAKE As Int
Failed to perform SSL handshake.
Constant Value: -11
- ERROR_FILE As Int
Generic file error.
Constant Value: -13
- ERROR_FILE_NOT_FOUND As Int
File not found.
Constant Value: -14
- ERROR_HOST_LOOKUP As Int
Server or proxy hostname lookup failed.
Constant Value: -2
- ERROR_IO As Int
Failed to read or write to the server.
Constant Value: -7
- ERROR_PROXY_AUTHENTICATION As Int
User authentication failed on proxy.
Constant Value: -5
- ERROR_REDIRECT_LOOP As Int
Too many redirects.
Constant Value: -9
- ERROR_TIMEOUT As Int
Connection timed out.
Constant Value: -8
- ERROR_TOO_MANY_REQUESTS As Int
Too many requests during this load.
Constant Value: -15
- ERROR_UNKNOWN As Int
Generic error.
Constant Value: -1
- ERROR_UNSAFE_RESOURCE As Int
Resource load was canceled by Safe Browsing.
Constant Value: -16
Added in API level 26
- ERROR_UNSUPPORTED_AUTH_SCHEME As Int
Unsupported authentication scheme (not basic or digest).
Constant Value: -3
- ERROR_UNSUPPORTED_SCHEME As Int
Unsupported URI scheme.
Constant Value: -10
- SAFE_BROWSING_THREAT_BILLING As Int
The resource was blocked because it may trick the user into a billing agreement.
This constant is only used when targetSdkVersion is at least Build.VERSION_CODES.Q. Otherwise, SAFE_BROWSING_THREAT_UNKNOWN is used instead.
Constant Value: 4
Added in API level 29
- SAFE_BROWSING_THREAT_MALWARE As Int
The resource was blocked because it contains malware.
Constant Value: 1
Added in API level 27
- SAFE_BROWSING_THREAT_PHISHING As Int
The resource was blocked because it contains deceptive content.
Constant Value: 2
Added in API level 27
- SAFE_BROWSING_THREAT_UNKNOWN As Int
The resource was blocked for an unknown reason.
Constant Value: 0
Added in API level 27
- SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE As Int
The resource was blocked because it contains unwanted software.
Constant Value: 3
Added in API level 27
ValueCallbackUri
This class cannot be initialized by the user.
Functions:
- IsInitialized As Boolean
- OnReceiveValue (Value As Object)
Pass the value that you get when the OnActivityResult event is fired and that is processed through the FileChooserParams1.ParseResult method.
Value: must be an object of single android.net.Uri or android.net.Uri array.
WebBackForwardList
This class cannot be initialized by the user.
Functions:
- GetItemAtIndex (Index As Int) As WebHistoryItem
Get the history item at the given index.
- IsInitialized As Boolean
Properties:
- CurrentIndex As Int [read only]
Get the index of the current history item. This index can be used to directly index into the array list.
- CurrentItem As WebHistoryItem [read only]
Get the current history item. This method returns not initialized WebHistoryItem if the list is empty.
- Size As Int [read only]
Get the total size of the back/forward list.
WebHistoryItem
This class cannot be initialized by the user.
Functions:
Properties:
- Favicon As Bitmap [read only]
Gets the favicon of this history item or not initialized bitmap if no favicon was found.
- OriginalUrl As String [read only]
Gets the original url of this history item. This was the requested url, the final url may be different as there might have been redirects while loading the site.
- Title As String [read only]
Gets the document title of this history item.
- Url As String [read only]
Return the url of this history item. The url is the base url of this history item.
WebResourceRequest
This class cannot be initialized by the user.
Functions:
- HasExternalAppIntent As Boolean
Returns True if this request contains intent to launch an external application, otherwise False.
- HasGesture As Boolean
Gets whether a gesture (such as a click) was associated with the request.
- HasMethod As Boolean
Returns True if has Method. Otherwise False.
- HasRequestHeaders As Boolean
Returns True if has RequestHeaders. Otherwise False.
- HasUrl As Boolean
Returns True if has Url. Otherwise False.
- IsForMainFrame As Boolean
Gets whether the request was made in order to fetch the main frame's document.
- IsRedirect As Boolean
Gets whether the request was a result of a server-side redirect.
Properties:
- ExternalAppIntent As Intent [read only]
Returns intent if this request is intended to launch an external application, otherwise returns not initialized intent.
- Method As String [read only]
Gets the method associated with the request, for example "GET".
- RequestHeaders As Map [read only]
Gets the headers associated with the request.
- Url As String [read only]
Gets the URL string for which the resource request was made.
- UrlAsUri As Object [read only]
Gets the URL as object of android.net.Uri for which the resource request was made.
WebResourceResponse
Functions:
- Initialize (MimeType As String, Encoding As String, Data As InputStream)
Initializes a resource response with the given MIME type, character encoding, and input stream.
MimeType: the resource response's MIME type, for example "text/html".
Encoding: the resource response's character encoding, for example "utf-8".
Data: the input stream that provides the resource response's data.
Added in API level 11.
- Initialize2 (MimeType As String, Encoding As String, StatusCode As Int, ReasonPhrase As String, ResponseHeaders As Map, Data As InputStream)
Initializes a resource response with the given parameters.
MimeType: the resource response's MIME type, for example "text/html".
Encoding: the resource response's character encoding, for example "utf-8".
StatusCode: the status code needs to be in the ranges [100, 299], [400, 599]. Causing a redirect by specifying a 3xx code is not supported.
ReasonPhrase: the phrase describing the status code, for example "OK". Must be non-empty. This value cannot be Null.
ResponseHeaders: the resource response's headers represented as a mapping of header name -> header value.
Data: the input stream that provides the resource response's data.
Added in API level 21
- IsInitialized As Boolean
- SetStatusCodeAndReasonPhrase (StatusCode As Int, ReasonPharse As String)
Sets the resource response's status code and reason phrase.
StatusCode: the status code needs to be in the ranges [100, 299], [400, 599]. Causing a redirect by specifying a 3xx code is not supported.
ReasonPharse: the phrase describing the status code, for example "OK". Must be non-empty. This value cannot be Null.
Added in API level 21.
Properties:
- Data As InputStream
Gets or sets the input stream that provides the resource response's data.
Added in API level 11.
- Encoding As String
Gets or sets the resource response's encoding.
Added in API level 11.
- MimeType As String
Gets or sets the resource response's MIME type.
Added in API level 11.
- ReasonPhrase As String [read only]
Gets the description of the resource response's status code.
Added in API level 21.
- ResponseHeaders As Map
Gets or sets the headers for the resource response.
Added in API level 21.
- StatusCode As Int [read only]
Gets the resource response's status code.
Added in API level 21.
WebSettings
Fields:
- ATTRIBUTION_BEHAVIOR_APP_SOURCE_AND_APP_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register app sources and app triggers from WebView.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_APP_SOURCE_AND_WEB_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register app sources (sources associated with the app package name) and web triggers (triggers associated with the eTLD+1) from WebView.
This is the default behavior.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_DISABLED As Int
AttributionRegistrationBehavior that disables source and trigger registration from WebView.
Note that the initial network call to the Attribution Source or Trigger URIs may still happen depending on the installed version of WebView, but any response is discarded and nothing will be stored on the device.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_WEB_SOURCE_AND_WEB_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register web sources and web triggers from WebView.
This option should only be used after applying to use web sources.
Field implemented from webkit Compat package.
- DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING As Int
In this mode WebView content will be darkened by a user agent unless web page supports dark theme. WebView determines whether web pages supports dark theme by the presence of color-scheme metadata containing "dark" value. If the metadata is not presented WebView content will be darkened by a user agent and prefers-color-scheme media query will evaluate to light.
Field implemented from webkit Compat package.
- DARK_STRATEGY_USER_AGENT_DARKENING_ONLY As Int
In this mode WebView content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. To avoid mixing two different darkening strategies, the prefers-color-scheme media query will evaluate to light.
Field implemented from webkit Compat package.
- DARK_STRATEGY_WEB_THEME_DARKENING_ONLY As Int
In this mode WebView content will always be darkened using dark theme provided by web page. If web page does not provide dark theme support WebView content will be rendered with a default theme.
Field implemented from webkit Compat package.
- FORCE_DARK_AUTO As Int
Enable force dark dependent on the state of the WebView parent view. If the WebView parent view is being automatically force darkened, then WebView content will be rendered so as to emulate a dark theme. WebViews that are not attached to the view hierarchy will not be inverted.
Field implemented from webkit Compat package.
- FORCE_DARK_OFF As Int
Disable force dark, irrespective of the force dark mode of the WebView parent. In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
Field implemented from webkit Compat package.
- FORCE_DARK_ON As Int
Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme.
Field implemented from webkit Compat package.
- LAYOUT_ALGORITHM_NARROW_COLUMNS As Object
- LAYOUT_ALGORITHM_NORMAL As Object
- LAYOUT_ALGORITHM_SINGLE_COLUMN As Object
- LAYOUT_ALGORITHM_TEXT_AUTOSIZING As Object
- LOAD_CACHE_ELSE_NETWORK As Int
- LOAD_CACHE_ONLY As Int
- LOAD_DEFAULT As Int
- LOAD_NO_CACHE As Int
- MENU_ITEM_NONE As Int
- MENU_ITEM_PROCESS_TEXT As Int
- MENU_ITEM_SHARE As Int
- MENU_ITEM_WEB_SEARCH As Int
- MIXED_CONTENT_ALWAYS_ALLOW As Int
- MIXED_CONTENT_COMPATIBILITY_MODE As Int
- MIXED_CONTENT_NEVER_ALLOW As Int
Functions:
- Initialize (WebViewObject As Object)
Initializes new class instance.
If UltimateWebView is used, variable declaration and initialization of this class is not required. In that case, the WebViewSettings can be found in the UltimateWebView1.Settings property.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object.
- IsInitialized As Boolean
Properties:
- AlgorithmicDarkeningAllowed As Boolean
Gets or sets whether algorithmic darkening is allowed. Algorithmic darkening is disallowed by default.
Added in API level 33
- AllowContentAccess As Boolean
Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default is enabled.
Added in API level 11
- AllowFileAccess As Boolean
Enables or disables file access within WebView. Note that this enables or disables file system access only. Assets and resources are still accessible using file:///android_asset and file:///android_res.
- AllowFileAccessFromFileURLs As Boolean
Gets or sets whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs.
Added in API level 16
Deprecated in API level 30
- AllowUniversalAccessFromFileURLs As Boolean
Gets or sets whether JavaScript running in the context of a file scheme URL can access content from any origin. This includes access to content from other file scheme URLs.
Added in API level 16
Deprecated in API level 30
- AttributionRegistrationBehavior As Int
Control how WebView interacts with Attribution Reporting.
WebView supports Attribution Reporting across apps and web pages by enabling the web content to register sources and triggers.
By default, attribution sources will be registered as attributed to the app, while triggers are attributed to the loaded web content (ATTRIBUTION_BEHAVIOR_APP_SOURCE_AND_WEB_TRIGGER). Apps should only need to change this default if they have a specific semantic for how they use WebView. In particular, in-app browsers should follow the steps to apply to the allowlist for registering web sources and then set the ATTRIBUTION_BEHAVIOR_WEB_SOURCE_AND_WEB_TRIGGER behavior.
If this setting is not supported by device, -1 will be returned.
Property implemented from webkit Compat package.
- BlockNetworkImage As Boolean
Gets or sets whether the WebView does not load image resources from the network.
- BlockNetworkLoads As Boolean
Gets or sets whether the WebView does not load any resources from the network.
- BuiltInZoomControls As Boolean
Gets or sets whether the zoom mechanisms built into WebView are being used.
- CacheMode As Int
Gets or sets the current setting for overriding the cache mode.
Values: LOAD_DEFAULT, LOAD_CACHE_ELSE_NETWORK, LOAD_NO_CACHE, or LOAD_CACHE_ONLY
- CursiveFontFamily As String
Gets or sets the cursive font family name. The default is "cursive".
- DatabaseEnabled As Boolean
Gets or sets whether the database storage API is enabled. The default value is false.
- DefaultFixedFontSize As Int
Gets or sets the default fixed font size. The default is 16. Values between 1 and 72.
- DefaultFontSize As Int
Gets or sets the default font size. The default is 16. Values between 1 and 72.
- DefaultTextEncodingName As String
Gets or sets the default text encoding name to use when decoding html pages. The default is "UTF-8".
- DisabledActionModeMenuItems As Int
Gets or sets the action mode menu items that are disabled, expressed in an integer field flag. The default value is MENU_ITEM_NONE.
Values: MENU_ITEM_NONE, MENU_ITEM_SHARE, MENU_ITEM_WEB_SEARCH, and MENU_ITEM_PROCESS_TEXT.
If this setting is not supported by device, -1 will be returned.
Property implemented from webkit Compat package.
- DisplayZoomControls As Boolean
Gets or sets whether the WebView displays on-screen zoom controls when using the built-in zoom mechanisms. The default is true.
- DomStorageEnabled As Boolean
Gets or sets whether the DOM storage API is enabled. The default value is false.
- EnterpriseAuthenticationAppLinkPolicyEnabled As Boolean
Gets or sets whether EnterpriseAuthenticationAppLinkPolicy if set by admin is allowed to have any effect on WebView.
EnterpriseAuthenticationAppLinkPolicy in WebView allows admins to specify authentication urls. When WebView is redirected to authentication url, and an app on the device has registered as the default handler for the url, that app is launched.
EnterpriseAuthenticationAppLinkPolicy is enabled by default.
If this setting is not supported by device, False will be returned.
Property implemented from webkit Compat package.
- FantasyFontFamily As String
Gets or sets the fantasy font family name. The default is "fantasy".
- FixedFontFamily As String
Gets or sets the fixed font family name. The default is "monospace".
- ForceDark As Int
Gets or sets the force dark mode for this WebView.
Values: FORCE_DARK_OFF, FORCE_DARK_AUTO, or FORCE_DARK_ON
If this setting is not supported by device, -1 will be returned.
Property implemented from webkit Compat package.
- ForceDarkStrategy As Int
Set how WebView content should be darkened.
The specified strategy is only used if force dark mode is on.
If this setting is not supported by device, -1 will be returned.
Property implemented from webkit Compat package.
- GeolocationDatabasePath As String [write only]
Gets or sets the path where the Geolocation databases should be saved. In order for Geolocation permissions and cached positions to be persisted, this method must be called with a path to which the application can write.
Added in API level 5
Deprecated in API level 24
- GeolocationEnabled As Boolean [write only]
Gets or sets whether Geolocation is enabled. The default is true.
- JavaScriptCanOpenWindowsAutomatically As Boolean
Gets or sets whether JavaScript can open windows automatically. This applies to the JavaScript function window.open(). The default is false.
- JavaScriptEnabled As Boolean
Gets or sets whether JavaScript is enabled. The default is false.
- LayoutAlgorithm As Object
Gets or sets the underlying layout algorithm. This will cause a re-layout of the WebView. The default is LAYOUT_ALGORITHM_NARROW_COLUMNS.
Values: LAYOUT_ALGORITHM_NARROW_COLUMNS, LAYOUT_ALGORITHM_SINGLE_COLUMN, LAYOUT_ALGORITHM_NORMAL and LAYOUT_ALGORITHM_TEXT_AUTOSIZING.
- LoadsImagesAutomatically As Boolean
Gets or sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme. Use BlockNetworkImage to control loading only of images specified using network URI schemes. Note that if the value of this setting is changed from false to true, all images resources referenced by content currently displayed by the WebView are loaded automatically. The default is true.
- LoadWithOverviewMode As Boolean
Gets or sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width. This setting is taken into account when the content width is greater than the width of the WebView control, for example, when UseWideViewPort is enabled. The default is false.
- MediaPlaybackRequiresUserGesture As Boolean
Gets or sets whether the WebView requires a user gesture to play media. The default is true.
- MinimumFontSize As Int
Gets or sets the minimum font size. The default is 8.
- MinimumLogicalFontSize As Int
Gets or sets the minimum logical font size. The default is 8.
- MixedContentMode As Int
Gets or sets the current behavior of the WebView with regard to loading insecure content from a secure origin.
Values: MIXED_CONTENT_NEVER_ALLOW, MIXED_CONTENT_ALWAYS_ALLOW or MIXED_CONTENT_COMPATIBILITY_MODE.
Added in API level 21
- NeedInitialFocus As Boolean [write only]
The default value is true.
- OffscreenPreRaster As Boolean
Gets or sets whether this WebView should raster tiles when it is offscreen but attached to a window.
If this setting is not supported by device, False will be returned.
Property implemented from webkit Compat package.
- SafeBrowsingEnabled As Boolean
Gets or sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. Safe Browsing is enabled by default for devices which support it.
If this setting is not supported by device, False will be returned.
Property implemented from webkit Compat package.
- SansSerifFontFamily As String
Gets or sets the sans-serif font family name. The default is "sans-serif".
- SaveFormData As Boolean
Gets or sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data. Therefore, the Webview form data save feature is disabled. Note that the feature will continue to be supported on older versions of Android as before.
Deprecated in API level 26
- SerifFontFamily As String
Gets or sets the serif font family name. The default is "sans-serif".
- StandardFontFamily As String
Gets or sets the standard font family name. The default is "sans-serif".
- SupportMultipleWindows As Boolean
Gets or sets whether the WebView whether supports multiple windows. If set to true, IGWebChromeClient must be implemented by the host application. The default is false.
- SupportZoom As Boolean
Gets or sets whether the WebView should support zooming using its on-screen zoom controls and gestures. The particular zoom mechanisms that should be used can be set with BuiltInZoomControls. The default is true.
- TextZoom As Int
Gets or sets the text zoom of the page in percent. The default is 100.
- UserAgentString As String
Gets or sets the WebView's user-agent string. If the string is null or empty, the system default value will be used.
- UseWideViewPort As Boolean
Gets or sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used.
WebSettings
This module contains only static methods and fields.
Fields:
- ATTRIBUTION_BEHAVIOR_APP_SOURCE_AND_APP_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register app sources and app triggers from WebView.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_APP_SOURCE_AND_WEB_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register app sources (sources associated with the app package name) and web triggers (triggers associated with the eTLD+1) from WebView.
This is the default behavior.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_DISABLED As Int
AttributionRegistrationBehavior that disables source and trigger registration from WebView.
Note that the initial network call to the Attribution Source or Trigger URIs may still happen depending on the installed version of WebView, but any response is discarded and nothing will be stored on the device.
Field implemented from webkit Compat package.
- ATTRIBUTION_BEHAVIOR_WEB_SOURCE_AND_WEB_TRIGGER As Int
AttributionRegistrationBehavior that allows apps to register web sources and web triggers from WebView.
This option should only be used after applying to use web sources.
Field implemented from webkit Compat package.
- DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING As Int
In this mode WebView content will be darkened by a user agent unless web page supports dark theme. WebView determines whether web pages supports dark theme by the presence of color-scheme metadata containing "dark" value. If the metadata is not presented WebView content will be darkened by a user agent and prefers-color-scheme media query will evaluate to light.
Field implemented from webkit Compat package.
- DARK_STRATEGY_USER_AGENT_DARKENING_ONLY As Int
In this mode WebView content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. To avoid mixing two different darkening strategies, the prefers-color-scheme media query will evaluate to light.
Field implemented from webkit Compat package.
- DARK_STRATEGY_WEB_THEME_DARKENING_ONLY As Int
In this mode WebView content will always be darkened using dark theme provided by web page. If web page does not provide dark theme support WebView content will be rendered with a default theme.
Field implemented from webkit Compat package.
- FORCE_DARK_AUTO As Int
Enable force dark dependent on the state of the WebView parent view. If the WebView parent view is being automatically force darkened, then WebView content will be rendered so as to emulate a dark theme. WebViews that are not attached to the view hierarchy will not be inverted.
Field implemented from webkit Compat package.
- FORCE_DARK_OFF As Int
Disable force dark, irrespective of the force dark mode of the WebView parent. In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
Field implemented from webkit Compat package.
- FORCE_DARK_ON As Int
Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme.
Field implemented from webkit Compat package.
- LAYOUT_ALGORITHM_NARROW_COLUMNS As Object
- LAYOUT_ALGORITHM_NORMAL As Object
- LAYOUT_ALGORITHM_SINGLE_COLUMN As Object
- LAYOUT_ALGORITHM_TEXT_AUTOSIZING As Object
- LOAD_CACHE_ELSE_NETWORK As Int
- LOAD_CACHE_ONLY As Int
- LOAD_DEFAULT As Int
- LOAD_NO_CACHE As Int
- MENU_ITEM_NONE As Int
- MENU_ITEM_PROCESS_TEXT As Int
- MENU_ITEM_SHARE As Int
- MENU_ITEM_WEB_SEARCH As Int
- MIXED_CONTENT_ALWAYS_ALLOW As Int
- MIXED_CONTENT_COMPATIBILITY_MODE As Int
- MIXED_CONTENT_NEVER_ALLOW As Int
WebViewAssetLoader
Fields:
- AssetPathUrl As String
URL prefix for load file from DirAsset.
- InternalPathUrl As String
URL prefix for load file from DirInternal.
- ResourcesPathUrl As String
URL prefix for load file from #AdditionalRes.
Functions:
- Initialize (Domain As String)
Initializes the new instance of WebViewAssetLoader.
Domain: set the domain for the WebViewAssetLoader. The domain can be of your choice or use e.g. Application.PackageName. The domain must be unique so that it does not match the domain of an already existing website. Pass Null or empty string to use default domain (appassets.androidplatform.net).
Important: The WebViewAssetLoader will not work in DEBUG mode, work's only in RELEASE mode.
- IsInitialized As Boolean
- ShouldInterceptRequest (Url As String) As WebResourceResponse
Call this method after ShouldInterceptRequest event from IGWebViewClient is fired. Return result of this method is WebResourceResponse. Pass this WebResourceResponse as return value for ShouldInterceptRequest event.
Url: string from WebResourceRequest passed from ShouldInterceptRequest event.
Use this method when you use IGWebViewClient from this library.
- ShouldInterceptRequest2 (Url As String) As Object
Call this method after shouldInterceptRequest event from custom WebViewClient is fired. Return result of this method is Object as android.webkit.WebResourceResponse. Pass this Object as return value for shouldInterceptRequest event.
Url: string from android.webkit.WebResourceRequest or url only passed from shouldInterceptRequest event.
Use this method when you use custom WebViewClient.
WebViewDatabase
Functions:
- ClearFormData
Clears any saved data for web forms.
In Android O, the platform has implemented a fully functional Autofill feature to store form data. Therefore, the Webview form data save and clear feature are disabled. Note that the feature will continue to be supported on older versions of Android as before.
Deprecated in API level 26
- ClearHttpAuthUsernamePassword
Clears any saved credentials for HTTP authentication. This method only clears the username and password stored in WebViewDatabase instance. The username and password are not read from the WebViewDatabase during WebViewClient's "ReceivedHttpAuthRequest" event. It is up to the app to do this or not.
The username and password used for http authentication might be cached in the network stack itself, and are not cleared when this method is called. WebView does not provide a special mechanism to clear HTTP authentication for implementing client logout. The client logout mechanism should be implemented by the Web site designer (such as server sending a HTTP 401 for invalidating credentials).
- GetHttpAuthUsernamePassword (Host As String, Realm As String) As Map
Retrieves HTTP authentication credentials for a given host and realm from the WebViewDatabase instance.
Host: the host to which the credentials apply
Realm: the realm to which the credentials apply
Returns map with Usernames as keys and Passwords as value. If there are no values saved for the specified Host and Realm, it returns an empty map.
- HasFormData As Boolean
Gets whether there is any saved data for web forms.
In Android O, the platform has implemented a fully functional Autofill feature to store form data. Therefore, the Webview form data save and clear feature are disabled. Note that the feature will continue to be supported on older versions of Android as before.
Deprecated in API level 26
- HasHttpAuthUsernamePassword As Boolean
Gets whether there are any saved credentials for HTTP authentication.
- Initialize (WebViewObject As Object)
Initializes new class instance.
If UltimateWebView is used, variable declaration and initialization of this class is not required. In that case, the WebViewDatabase can be found in the UltimateWebView1.WebViewDatabase property.
WebViewObject: native B4A WebView or UltimateWebView or any other wrapped WebView object.
- IsInitialized As Boolean
- SetHttpAuthUsernamePassword (Host As String, Realm As String, Username As String, Password As String)
Stores HTTP authentication credentials for a given host and realm to the WebViewDatabase instance.
Host: the host to which the credentials apply
Realm: the realm to which the credentials apply
Username: the username
Password: the password