B4A Library UltimateWebView Custom View

IMPORTANT!!!
Library deprecated. Use UltimateWebView2 instead.


The purpose of the library is to implement all important classes in one library in order to make work as easy as possible. The library will be upgraded over time by adding new features and protocols.

For full library functionality, copy the following into the manifest:
Manifest:
'Important
SetApplicationAttribute(android:usesCleartextTraffic,"true")
AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
'---------------------
'Camera Permissions
AddPermission(android.permission.CAMERA)
AddPermission(android.permission.RECORD_AUDIO)
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
AddPermission(android.permission.MICROPHONE)
AddPermission("android.hardware.camera")
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="true" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false" />)
'---------------------

'Geolocation Permissions
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
'------------------------

AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

UltimateWebView is a Custom View Library and it is possible to add a View through the Designer.

Sample project:
B4AExample:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

#BridgeLogger: True

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private txtUrl As EditText
    Private btnGo As Button
    Private UltimateWebView1 As UltimateWebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
 
    UltimateWebView1.SetWebViewClient 'Sets WebViewClient and its Events.
    UltimateWebView1.SetWebChromeClient 'Sets WebChromeClient and its Events.
    'Other UltimateWebViewSettings
    UltimateWebView1.Settings.JavaScriptEnabled=True
    UltimateWebView1.Settings.AllowContentAccess=True
    UltimateWebView1.Settings.AllowFileAccess=True
    UltimateWebView1.Settings.AppCacheEnabled=True
    UltimateWebView1.Settings.CacheMode=UltimateWebView1.Settings.CacheMode_LOAD_DEFAULT
    UltimateWebView1.Settings.JavaScriptCanOpenWindowsAutomatically=True
    UltimateWebView1.Settings.DisplayZoomControls=False
    UltimateWebView1.Settings.DomStorageEnabled=True
    UltimateWebView1.Settings.MediaPlaybackRequiresUserGesture=False
    UltimateWebView1.Settings.AllowFileAccessFromFileURLs=True
    UltimateWebView1.Settings.AllowUniversalAccessFromFileURLs=True
    UltimateWebView1.Settings.GeolocationEnabled=True
    UltimateWebView1.SetDownloadListener 'Sets and start DownloadListener'
 
    'CookieManager Settings to accept all cookies
    UltimateWebView1.CookieManager.AcceptCookies=True
    UltimateWebView1.CookieManager.AcceptThirdPartyCookies=True
    UltimateWebView1.CookieManager.AcceptFileSchemeCookies=True
    UltimateWebView1.CookieManager.Flush
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
        ExitApplication
    End If
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
    If KeyCode=KeyCodes.KEYCODE_BACK Then
        If UltimateWebView1.CanGoBack=True Then
            UltimateWebView1.GoBack
            Return True
        Else
            Return False
        End If
    Else
        Return False
    End If
End Sub

Sub btnGo_Click
    'You can use LoadUrl2 like in code bellow
    '--------------------------
    'Dim Headerrs As Map
    'Headerrs.Initialize
    'Headerrs.Put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36")
    'UltimateWebView1.LoadUrl2(txtUrl.Text,Headerrs)
    '---------------------------
 
    UltimateWebView1.LoadUrl(txtUrl.Text)
End Sub

Sub UltimateWebView1_FileDownloadInitialized (DownloadProperties1 As DownloadProperties) 'When click to download link or button this event will bi fired.
    Log("Download INITIALIZED")
    'DownloadProperties fields:
    '---------------------------------
    'Log(DownloadProperties1.url)
    'Log(DownloadProperties1.userAgent)
    'Log(DownloadProperties1.contentDisposition)
    'Log(DownloadProperties1.mimeType)
    'Log(DownloadProperties1.contentLength)
    'Log(DownloadProperties1.cookies)
    'Log(DownloadProperties1.fileName)
    'Log(DownloadProperties1.FileExtension)
    'Log(DownloadProperties1.DownloadID)
    '---------------------------------
 
    UltimateWebView1.StartFileDownload(DownloadProperties1,"TEST",True,True) 'File will be downloaded with native DownloadManager. If you want internall download, you can use your own method with parameters from DownloadProperties.
End Sub

Sub UltimateWebView1_FileDownloadStarted (DownloadProperties1 As DownloadProperties)
    Log("Download STARTED")
    'Log(DownloadProperties1.url)
    'Log(DownloadProperties1.userAgent)
    'Log(DownloadProperties1.contentDisposition)
    'Log(DownloadProperties1.mimeType)
    'Log(DownloadProperties1.contentLength)
    'Log(DownloadProperties1.cookies)
    'Log(DownloadProperties1.fileName)
    'Log(DownloadProperties1.FileExtension)
    'Log(DownloadProperties1.DownloadID)
End Sub

Sub UltimateWebView1_FileDownloadCompleted (Success As Boolean, DownloadProperties1 As DownloadProperties)
    Log("Download COMPLETED; Success:" & Success)
    'Log(DownloadProperties1.url)
    'Log(DownloadProperties1.userAgent)
    'Log(DownloadProperties1.contentDisposition)
    'Log(DownloadProperties1.mimeType)
    'Log(DownloadProperties1.contentLength)
    'Log(DownloadProperties1.cookies)
    'Log(DownloadProperties1.fileName)
    'Log(DownloadProperties1.FileExtension)
    'Log(DownloadProperties1.DownloadID)
End Sub

Private Sub UltimateWebView1_OverrideUrl (WebResourceRequest1 As WebResourceRequest) As Boolean
    'Log(WebResourceRequest1.GetUrl)
    'Log(WebResourceRequest1.GetMethod)
    'Log(WebResourceRequest1.HasGesture)
    'Log(WebResourceRequest1.IsForMainFrame)
    'Log(WebResourceRequest1.IsRedirect)
    'Dim M As Map=WebResourceRequest1.GetRequestHeaders
    'If M.IsInitialized Then
        'For i=0 To M.Size-1
            'Log(M.GetKeyAt(i))
            'Log(M.GetValueAt(i))
        'Next
    'End If
    Return False
End Sub

Sub UltimateWebView1_PageFinished (Url As String)
 
End Sub

Sub UltimateWebView1_PageStarted (Url As String, FavIcon As Bitmap)
    'If FavIcon<>Null Then
        'do stuff...
    'End If
End Sub

Sub UltimateWebView1_PageLoadingProgressChanged(Progress As Int)
 
End Sub

Sub UltimateWebView1_ReceivedIcon (Icon As Bitmap)
    'If Icon<>Null Then
    'do stuff...
    'End If
End Sub

Sub UltimateWebView1_ReceivedTitle (Title As String)
 
End Sub

'Very important event for UltimateWebView permissions request!!!
Sub UltimateWebView1_PermissionRequest (RequestedPermission As String)
    Dim Permissions As RuntimePermissions
    Permissions.CheckAndRequest(RequestedPermission)
    Wait For Activity_PermissionResult (Permission As String, result As Boolean)
    UltimateWebView1.GrantPermission(result)
End Sub

Sub UltimateWebView1_ScaleChanged (OldScale As Float, NewScale As Float)
 
End Sub

Private Sub UltimateWebView1_ReceivedError (WebResourceRequest1 As WebResourceRequest, WebResourceError1 As WebResourceError)
    'Log("ReceivedError")
    'Log(WebResourceRequest1.GetUrl)
    'Log(WebResourceError1.Description)
    'Log(WebResourceError1.ErrorCode)
End Sub

Private Sub UltimateWebView1_ReceivedHttpError (WebResponseRequest1 As WebResourceRequest, WebResourceResponse1 As WebResourceResponse)
    'Log("ReceivedHttpError")
    'Log(WebResponseRequest1.GetUrl)
    'Log(WebResourceResponse1.Encoding)
    'Log(WebResourceResponse1.StatusCode)
End Sub

Private Sub UltimateWebView1_ReceivedHttpAuthRequest (HttpAuthHandler1 As HttpAuthHandler, HttpAuthRequestProperties1 As HttpAuthRequestProperties)
    'Log("ReceivedHttpAuthRequest")
    'Log(HttpAuthRequestProperties1.Host)
    'Log(HttpAuthRequestProperties1.Realm)
End Sub

Private Sub UltimateWebView1_ReceivedLoginRequest (LoginRequestProperties1 As LoginRequestProperties)
    'Log("ReceivedLoginRequest")
    'Log(LoginRequestProperties1.Realm)
    'Log(LoginRequestProperties1.Account)
    'Log(LoginRequestProperties1.Args)
End Sub

Private Sub UltimateWebView1_UpdateVisitedHistory (Url As String, IsReload As Boolean)
    'Log("UpdateVisitedHistory")
    'Log(Url)
    'Log(IsReload)
End Sub


Private Sub UltimateWebView1_PageCommitVisible (Url As String)
 
End Sub

Private Sub UltimateWebView1_ShouldInterceptRequest (Request As WebResourceRequest) As WebResourceResponse
    'Log("ShouldInterceptRequest")
    'Log(Request.GetUrl)
    'Dim ins As InputStream
    'ins.InitializeFromBytesArray(Array As Byte(100,231,155),0,3)
    'Dim Response As WebResourceResponse
    'Response.Initialize
    'Response.Create("text/plain","utf-8",ins)
    'Return Response
    Return Null
End Sub


Private Sub UltimateWebView1_JsAlert (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean
    'Log("JsAlert")
    'Log(JsProperties1.Url)
    'Log(JsProperties1.Message)
    'Log(JsProperties1.DefaultValue)
    'JsResult1.Confirm
    Return False
End Sub

Private Sub UltimateWebView1_JsBeforeUnload (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean
    'Log("JsBeforeUnload")
    'Log(JsProperties1.Url)
    'Log(JsProperties1.Message)
    'Log(JsProperties1.DefaultValue)
    'JsResult1.Confirm
    Return False
End Sub

Private Sub UltimateWebView1_JsConfirm (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean
    'Log("JsConfirm")
    'Log(JsProperties1.Url)
    'Log(JsProperties1.Message)
    'Log(JsProperties1.DefaultValue)
    'JsResult1.Confirm
    Return False
End Sub

UltimateWebView
Author:
Ivica Golubovic
Version: 1.1

Changes:
  • Method GetWebView is removed from UltimateWebView Class.
  • Property WebView (get/set) added to UltimateWebView Class. You can now use this property to set existing WebView to UltimateWebView.
  • Added method ClearFormData.
  • Added method ClearMatches.
  • Added method ClearSslPreferences.
  • Added method ComputeScroll.
  • Added class WebBackForwardList.
  • Added type WebHistoryItem to class WebBackForwardList.
  • Added method CopyBackForwardList.
  • Added method FindAllAsync.
  • Added method FindNext.
  • Added method FlingScroll.
You can now import an existing WebView object into UltimateWebView, it is not necessary to add an UltimateWebView object through the Designer.
Example:
Example:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private WebView1 As WebView
    Private UltimateWebView1 As UltimateWebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
 
    'First Initialize UltimateWebView
    UltimateWebView1.Initialize(Me,"UltimateWebView1")
    'Import native WebView into UltimateWebView
    UltimateWebView1.WebView=WebView1
 
    UltimateWebView1.SetWebViewClient
    UltimateWebView1.SetWebChromeClient
    UltimateWebView1.Settings.JavaScriptEnabled=True
    UltimateWebView1.Settings.AllowContentAccess=True
    UltimateWebView1.Settings.AllowFileAccess=True
    UltimateWebView1.Settings.AppCacheEnabled=True
    UltimateWebView1.Settings.CacheMode=UltimateWebView1.Settings.CacheMode_LOAD_DEFAULT
    UltimateWebView1.Settings.JavaScriptCanOpenWindowsAutomatically=True
    UltimateWebView1.Settings.DisplayZoomControls=False
    UltimateWebView1.Settings.DomStorageEnabled=True
    UltimateWebView1.Settings.MediaPlaybackRequiresUserGesture=False
    UltimateWebView1.Settings.AllowFileAccessFromFileURLs=True
    UltimateWebView1.Settings.AllowUniversalAccessFromFileURLs=True
    UltimateWebView1.Settings.GeolocationEnabled=True
    UltimateWebView1.SetDownloadListener
 
    UltimateWebView1.CookieManager.AcceptCookies=True
    UltimateWebView1.CookieManager.AcceptThirdPartyCookies=True
    UltimateWebView1.CookieManager.AcceptFileSchemeCookies=True
    UltimateWebView1.CookieManager.Flush
End Sub

A very important event for the permissions required for WebRTC, Geolocation, etc. Without this event permisions will be denied.
Permission Event:
Sub UltimateWebView1_PermissionRequest (RequestedPermission As String)
    Dim Permissions As RuntimePermissions
    Permissions.CheckAndRequest(RequestedPermission)
    Wait For Activity_PermissionResult (Permission As String, result As Boolean)
    UltimateWebView1.GrantPermission(result)
End Sub

UltimateWebView
Author:
Ivica Golubovic
Version: 1.2

Changes:
  • Added event FileChooserInitialized.
  • Added class FileChooserParams.
  • Added method FileChooserStart.
  • Added automatic permissions requests for UploadFileChooser.
  • Added the ability to upload multiple files with UploadFileChooser if allowed.
  • Added event OverrideUrlWithExternalAppIntent.
FileChooserInitialized event added. It will be activated when a Web source requires uploading a file or multiple files. To start FileChooser, call the FileChooserStart method or use event objects the way you want. Do not add this event if you do not want your application to have this feature.
Example::
Private Sub UltimateWebView1_FileChooserInitialized (FilePathCallback As Object, FileChooserParams1 As FileChooserParams)
    'ForceIsCaptureEnabled As Boolean:
    '    True: Use resources such as camera, microphone, etc. by force if the required file format is appropriate.
    '    False: Use a predefined value assigned to FileChooserParams.
    UltimateWebView1.FileChooserStart(FilePathCallback,FileChooserParams1,True) 'Use this method or use your own method from given parameters
End Sub

Added event OverrideUrlWithExternalAppIntent which will process the request to launch an external application outside of UltimateWebView (e.g. PlayStore, Maps, AppGalery, applies to all installed applications). The result of the event is an Intent which you can use in the way you want (e.g. StartActivity (Intent) - opens the application or application chooser, depending on the case).
Example::
Sub UltimateWebView1_OverrideUrlWithExternalAppIntent (WebResourceRequest1 As WebResourceRequest, ExternalAppIntent As Intent) As Boolean
    'ExternalAppIntent - Intent to use
    StartActivity(ExternalAppIntent) 'You can use this method or do with event what ever you want
    Return True 'True to stop page loading and handling event, False to finish loading page (Error web page will be shown)
End Sub

UltimateWebView
Author:
Ivica Golubovic
Version: 1.3
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-859400


UltimateWebView
Author:
Ivica Golubovic
Version: 1.4
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-860033

UltimateWebView
Author:
Ivica Golubovic
Version: 1.5
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-861510

UltimateWebView
Author:
Ivica Golubovic
Version: 1.6
Changes: Visit this post for description: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-864977

UltimateWebView
Author:
Ivica Golubovic
Version: 1.7
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-866430

UltimateWebView
Author:
Ivica Golubovic
Version: 2.0
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-869686

UltimateWebView
Author:
Ivica Golubovic
Version: 2.01
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-869704

UltimateWebView
Author:
Ivica Golubovic
Version: 2.1
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-871370

UltimateWebView
Author:
Ivica Golubovic
Version: 2.11
Changes: Fixed bug where object is not visible in Designer (AddView-CustomView-UltimateWebView).

UltimateWebView
Author:
Ivica Golubovic
Version: 2.12
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-875746

UltimateWebView
Author:
Ivica Golubovic
Version: 2.20
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-906883

UltimateWebView
Author:
Ivica Golubovic
Version: 2.21
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-908288

UltimateWebView
Author:
Ivica Golubovic
Version: 2.3
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-912804

UltimateWebView
Author:
Ivica Golubovic
Version: 2.31
Changes: Visit this post: https://www.b4x.com/android/forum/threads/ultimatewebview-custom-view.135666/post-914392

Library references htm file is packed together with jar and xml file.

If this library makes your work easier and saves time in creating your application, please make a donation.
 
Last edited:
I tried to test properties such as LoadWithOverviewMode or UseWideViewPort and couldn't see them working anywhere.

Take, for example, the free channel https://www.cbs.com/. These Properties do not affect the display of the site in any way.

What's the matter here? I tried for many other sites - the result is the same.
 

gregchao

Active Member
Licensed User
Longtime User
Thank you for this library. I needed it to use the "CaptureScreenshotToBitmap" option.

For those of you who are interested in using this library in a B4xPages application, the key is to create an Activity Module rather than a B4xPages module and put the Ultimate code in this module. Also, I needed to check "SetWebViewClient" in Designer.

I have created an example that can be downloaded here.

https://www.dropbox.com/s/o4sgioxtjj0uylv/UltimateWebTest.zip?dl=0
 

gregchao

Active Member
Licensed User
Longtime User
Why? You can add a "classic" WebView to the Root of a B4XPage and get the Bitmap (B4XBitmap) simply writing Root.Snapshot.
(This doesn't mean this isn't a very useful library)
Thanks. Agreed. Your approach is simpler.
 
Last edited:

Apip Bayok

Member
Hai,
I try to create small project example using B4Xpage, but some or all event like Override and PageFinish not triggered, can you help me, maybe the mistake it's on me..
Thank You
 

peacemaker

Expert
Licensed User
Longtime User
_OverrideUrl
Question is under which Android version: second sub works from API level 24 and above.

I use such:
Private Sub wv_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
#If debug
    Log("override=" & Url)
#End If
    Return False
End Sub

Private Sub wv_OverrideUrl2 (WebResourceRequest1 As WebResourceRequest) As Boolean 'Works from API level 24 and above. WebViewClient required.
    Dim URL As String = WebResourceRequest1.GetUrl
    Log("OverrideUrl2 = URL)
    wv_OverrideUrl(URL)
    Return False
End Sub

Any public URL with such JS web-page to check ?
 

mehdipass

Active Member
Hi,
When I click the back button this error occurs.
Why?

Error:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at com.uwebview.ultimatewebview$MyWebViewClient.shouldOverrideKeyEvent(ultimatewebview.java:3963)
    at jm.dispatchKeyEvent(PG:15)
    at com.android.webview.chromium.WebViewChromium.dispatchKeyEvent(PG:7)
    at android.webkit.WebView.dispatchKeyEvent(WebView.java:2952)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:601)
    at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1923)
    at android.app.Activity.dispatchKeyEvent(Activity.java:4107)
    at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:454)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5744)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5612)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5236)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5087)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5293)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5087)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5269)
    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5439)
    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:3101)
    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2644)
    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2635)
    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:3078)
    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:143)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:363)
    at android.os.Looper.loop(Looper.java:173)
    at android.app.ActivityThread.main(ActivityThread.java:8178)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
 

Ivica Golubovic

Active Member
Licensed User
Hi,
When I click the back button this error occurs.
Why?

Error:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at com.uwebview.ultimatewebview$MyWebViewClient.shouldOverrideKeyEvent(ultimatewebview.java:3963)
    at jm.dispatchKeyEvent(PG:15)
    at com.android.webview.chromium.WebViewChromium.dispatchKeyEvent(PG:7)
    at android.webkit.WebView.dispatchKeyEvent(WebView.java:2952)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1933)
    at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:601)
    at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1923)
    at android.app.Activity.dispatchKeyEvent(Activity.java:4107)
    at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:454)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5744)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5612)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5236)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5087)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5293)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5087)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5060)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5113)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5079)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5269)
    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5439)
    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:3101)
    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2644)
    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2635)
    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:3078)
    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:143)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:363)
    at android.os.Looper.loop(Looper.java:173)
    at android.app.ActivityThread.main(ActivityThread.java:8178)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
You must share more information like android version, sdk number, program code. It is hard to solve any problem only from error code.
 

max123

Well-Known Member
Licensed User
Longtime User

Ivica Golubovic

Active Member
Licensed User
Version 2.20 released. Library is now compatible with B4XPages. Download library and documents from first post.

Changes:
  • Added property SwipeToReload (@peacemaker gives me an idea) to UltimateWebView class.
  • Added event OverrideSwipeToReload (UrlToReload As String) As Boolean to UltimateWebView class.
  • Added method SetLayout (Left As Int, Top As Int, Width As Int, Height As Int) to UltimateWebView class.
  • Added method SetLayoutAnimated(Duration As Int,Left As Int,Top As Int,Width As Int,Height As Int) to UltimateWebView class.
  • Added method SetVisibleAnimated(Duration As Int,Visible As Boolean) to UltimateWebView class.
 

max123

Well-Known Member
Licensed User
Longtime User
Thank you for great improvements!
 

Ivica Golubovic

Active Member
Licensed User
Version 2.3 released. Library is now compatible with B4XPages. Download library and documents from first post.

Changes:
  • Added method AllowFullScreenVideo (Allowed As Boolean,ForceLandscape As Boolean) to UltimateWebView class.
  • Library reorganized and deleted unnecessary class imports.
  • Bugs fixed.
AllowFullScreenVideo enables to display videos in full screen (eg youtube videos and other video streaming services). In order for this method to work, it is necessary to prevent Activity redrawing in case of screen orientation changed because all views will lose their instances and restart to initial instances. For these purposes I recommend using the SoftOrientation library. To download the library and read instructions for using the SoftOrientation library, click here.
 

Ivica Golubovic

Active Member
Licensed User
Version 2.31 released. Library is now compatible with B4XPages. Download library and documents from first post.

Changes:
  • Edited event: ShouldInterceptRequest (Url As String) As WebResourceResponse 'Works from API level 11 to API level 20. WebViewClient required.
  • Added event: ShouldInterceptRequest2 (Request As WebResourceRequest) As WebResourceResponse 'Works from API level 21 and above. WebViewClient required.
  • Removed unnecessary imports and unnecessary routines to reduce the size of the library and therefore the size of the final application.
  • Edited WebResourceRequest class (removed Get from properties names).
  • Edited WebResourceResponse class (removed Create3 method and edited Initialize method).
 

Ivica Golubovic

Active Member
Licensed User
IMPORTANT!!!
After one year of its existence, UltimateWebView migrated to WebkitLibrariesSet. The UltimateWebView library will no longer be upgraded in its current form. This thread will be neglected and there will be no answers to the questions asked in this thread. I recommend that you switch your projects in which you use UltimateWebView to WebkitLibrariesSet as soon as possible. To download the set of libraries and more information visit the following thread:

 

max123

Well-Known Member
Licensed User
Longtime User
Oooh.... my application use a lot UltimateWebView. Panic o_O
 
Top