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:

Ivica Golubovic

Active Member
Licensed User
very good.
again error on load layout.
but error change.

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 33 (Main)
java.lang.RuntimeException: Cannot parse: null as boolean
    at anywheresoftware.b4a.BA.parseBoolean(BA.java:629)
    at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:699)
    at com.uwebview.ultimatewebview._afterloadlayout(ultimatewebview.java:302)
    at com.uwebview.ultimatewebview.callSub(ultimatewebview.java:3061)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1066)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
    at com.uwebview.ultimatewebview._designercreateview(ultimatewebview.java:835)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at com.test.net.main._activity_create(main.java:392)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at com.test.net.main.afterFirstLayout(main.java:105)
    at com.test.net.main.access$000(main.java:17)
    at com.test.net.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5293)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
** Activity (main) Resume **
Try version 2.01. Problem fixed.
 

Ivica Golubovic

Active Member
Licensed User
no.not work
Sorry man, it's my fault. I forgot to put in a new B4AExample project after some system stuff related to Custom View properties was replaced in the library. The problem in B4AExample has been solved by deleting the UltimateWebView object through the designer and adding a new one. Get the new B4AExample from first post. Thanks again for pointing me to the problem.
 

Ivica Golubovic

Active Member
Licensed User
Can I suggest that you move the description - the motivation that led you to develop this library - to the beginning of the thread, rather than after the very long list of its members? :)
Okay, thank you for the useful advice. I will consider how to redesign the first post because the references are really very long. Maybe I'll remove the references from the first post.
 

Ivica Golubovic

Active Member
Licensed User
Version 2.1 released. Download library and documents from first post.

Changes:
  • Added method LoadHTMLString (HTMLString As String) to UltimateWebView class.
  • Edited event OnUnhandledKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) 'Works from API level 1 to API level 21. WebViewClient required.
  • Added event OnUnhandledKeyEvent2 (KeyCode As Int, AndroidViewKeyEvent As Object) As Boolean 'Works from API level 28 and above.
  • Edited event OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event OverrideUrl2 (WebResourceRequest1 As WebResourceRequest) As Boolean 'Works from API level 24 and above. WebViewClient required.
  • Edited event OverrideUrlWithExternalAppIntent (Url As String, ExternalAppIntent As Intent) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event OverrideUrlWithExternalAppIntent2 (WebResourceRequest1 As WebResourceRequest, ExternalAppIntent As Intent) As Boolean 'Works from API level 24 and above. WebViewClient required.
  • Edited event ReceivedError (ErrorCode As Int, Description As String, FailingUrl As String) 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event ReceivedError2 (WebResourceRequest1 As WebResourceRequest, WebResourceError1 as WebResourceError) 'Works from API level 23 and above. WebViewClient required.
 

Apip Bayok

Member
very good.
again error on load layout.
but error change.

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 33 (Main)
java.lang.RuntimeException: Cannot parse: null as boolean
    at anywheresoftware.b4a.BA.parseBoolean(BA.java:629)
    at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:699)
    at com.uwebview.ultimatewebview._afterloadlayout(ultimatewebview.java:302)
    at com.uwebview.ultimatewebview.callSub(ultimatewebview.java:3061)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1066)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
    at com.uwebview.ultimatewebview._designercreateview(ultimatewebview.java:835)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at com.test.net.main._activity_create(main.java:392)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at com.test.net.main.afterFirstLayout(main.java:105)
    at com.test.net.main.access$000(main.java:17)
    at com.test.net.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5293)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
** Activity (main) Resume **
still face this error, UltimateWebView v2.10 device android 11, when I remove ultimatewebview object on designer and try to add new one it's not show on the list.
 

Ivica Golubovic

Active Member
Licensed User
still face this error, UltimateWebView v2.10 device android 11, when I remove ultimatewebview object on designer and try to add new one it's not show on the list.
Very strange, I tested on Android 11, 10, 9, 7 and 6 and it works without problems. I'll check again to see what could be causing the problem. Have you tried downloading the new B4AExample and uninstalling the old one before installing?
 

Ivica Golubovic

Active Member
Licensed User
Version 2.12 released. Download library and documents from first post.

Changes:
  • Edited method LoadHTMLString (HTMLString As String)
    • Fixed a bug that in some cases this method did not display the contents of the HTML string.
  • Edited method LoadFileFromDirAssets (FileName As String, IncludeSubFolders As Boolean)
    • IncludeSubFolders As Boolean - True for an html file whose objects are in a subfolder or multiple subfolders. False for an html file that has no additional objects in the subfolders but only at the root of the Asset folder. For a non html files value is not important (True or False).
    • It is now possible to use the standard file scheme to open files in subfolders through an HTML file. E.g:
    • Example::
      "file:///android_asset/subfolder/file.png"
  • Method SetWebChromeClient become property WebChromeClientEnabled (true or false).
    • B4X:
      UltimateWebView1.SetWebChromeClient  'old
      'Replace with
      UltimateWebView1.WebChromeClientEnabled=True 'or False for disable
  • Method SetWebViewClient become property WebViewClientEnabled (true or false).
    • B4X:
      UltimateWebView1.SetWebViewClient  'old
      'Replace with
      UltimateWebView1.WebViewClientEnabled=True 'or False for disable
  • Method SetDownloadListener become property DownloadListenerEnabled (true or false).
    • B4X:
      UltimateWebView1.SetDownloadListener  'old
      'Replace with
      UltimateWebView1.DownloadListenerEnabled=True 'or False for disable
  • The method FileChooserStart (for file upload) now starts the application chooser instead of the default file chooser.
 

max123

Well-Known Member
Licensed User
Longtime User
Hi @Ivica Golubovic, you know because initializing JSInterface inside a Class this way fails?
B4X:
JSInterface.Initialize(Me)

I still search to port this @stevel05 library to B4A but app crashes on this line.
https://www.b4x.com/android/forum/threads/codemirror-wrapper-and-example.125775/

Log do not help, just says: Error occurred on line: 147 (CodeMirrorWrapper)

Many Thanks

Here the unfiltered log, for sure you are better than me to know it.
Logger connesso a: asus Nexus 7
--------- beginning of main
ClassLoader referenced unknown path: /data/app/b4a.example.codemirror-2/lib/arm
Starting remote logger. Port: 9638
Use EGL_SWAP_BEHAVIOR_PRESERVED: true
<qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
Initialized EGL, version 1.4
*** Debugger waiting for connection (0) ***
0xaeef6000 Launching thread(s), CPUs 4
After accept
*** Debugger waiting for connection (1) ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Class not found: b4a.example.codeeditor, trying: b4a.example.codemirror.codeeditor
Class not found: b4a.example.codemirrorwrapper, trying: b4a.example.codemirror.codemirrorwrapper
Class not found: b4a.example.b4xplusminus, trying: b4a.example.codemirror.b4xplusminus
File.DirInternal: /data/user/0/b4a.example.codemirror/files
XUI.DefaultFolder: /data/user/0/b4a.example.codemirror/files
Background sticky concurrent mark sweep GC freed 35167(1606KB) AllocSpace objects, 1(40KB) LOS objects, 25% free, 8MB/11MB, paused 701us total 135.650ms
Loading com.google.android.webview version 99.0.4844.88 (code 484408800)
Loaded version=99.0.4844.88 minSdkVersion=23 isBundle=true multiprocess=false packageId=2
Successfully loaded native library
Flushed 9 samples from 9 histograms.
[WARNING:dns_config_service_android.cc(114)] Failed to read DnsConfig.
Skipped 43 frames! The application may be doing too much work on its main thread.
ignoring event: onlayoutchangelistener_event
validate_display:255 error 3008 (EGL_BAD_DISPLAY)
validate_display:255 error 3008 (EGL_BAD_DISPLAY)
Error occurred on line: 147 (CodeMirrorWrapper) <<<<<<<<<<<<<<<<<<<< ERROR HERE
java.lang.ClassNotFoundException: tils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currenttheme=
, filesfolder=/data/user/0/b4a.example.codemirror/files, jsinterface=[device=anywheresoftware.b4a.phone.Phone@aae679d, jsinterfacejo=(JavaObject) Not initialized, mcallback=[cmw_utils=null, code=, currentth
Message longer than Log limit (4000). Message was truncated.
java.net.SocketException: Socket closed
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:189)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom(IoBridge.java:549)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
at java.net.PlainSocketImpl.-wrap0(PlainSocketImpl.java)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
at java.io.BufferedInputStream.read(BufferedInputStream.java:234)
at anywheresoftware.b4a.shell.ShellConnector.readControlData(ShellConnector.java:191)
at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:186)
at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
at java.lang.Thread.run(Thread.java:818)
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
ClassLoader referenced unknown path: /data/app/b4a.example.codemirror-2/lib/arm
Starting remote logger. Port: 9638
After accept
Use EGL_SWAP_BEHAVIOR_PRESERVED: true
<qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
Initialized EGL, version 1.4
*** Debugger waiting for connection (0) ***
0xab49d000 Launching thread(s), CPUs 4
*** Debugger waiting for connection (1) ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Class not found: b4a.example.codeeditor, trying: b4a.example.codemirror.codeeditor
Class not found: b4a.example.codemirrorwrapper, trying: b4a.example.codemirror.codemirrorwrapper
Class not found: b4a.example.b4xplusminus, trying: b4a.example.codemirror.b4xplusminus
File.DirInternal: /data/user/0/b4a.example.codemirror/files
XUI.DefaultFolder: /data/user/0/b4a.example.codemirror/files
wrapper.css already exists
Updating version.txt (Copy from Assets)
Loading com.google.android.webview version 99.0.4844.88 (code 484408800)
Loaded version=99.0.4844.88 minSdkVersion=23 isBundle=true multiprocess=false packageId=2
Successfully loaded native library
Flushed 9 samples from 9 histograms.
[WARNING:dns_config_service_android.cc(114)] Failed to read DnsConfig.
Background partial concurrent mark sweep GC freed 28082(1481KB) AllocSpace objects, 3(60KB) LOS objects, 39% free, 9MB/16MB, paused 9.307ms total 48.370ms
Skipped 33 frames! The application may be doing too much work on its main thread.
ignoring event: onlayoutchangelistener_event
validate_display:255 error 3008 (EGL_BAD_DISPLAY)
validate_display:255 error 3008 (EGL_BAD_DISPLAY)
java.net.SocketException: Socket closed
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:189)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom(IoBridge.java:549)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
at java.net.PlainSocketImpl.-wrap0(PlainSocketImpl.java)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
at java.io.BufferedInputStream.read(BufferedInputStream.java:234)
at anywheresoftware.b4a.shell.ShellConnector.readControlData(ShellConnector.java:191)
at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:186)
at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
at java.lang.Thread.run(Thread.java:818)
java.net.SocketException: Socket closed
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:189)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom(IoBridge.java:549)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
at java.net.PlainSocketImpl.-wrap0(PlainSocketImpl.java)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
at java.io.BufferedInputStream.read(BufferedInputStream.java:234)
at anywheresoftware.b4a.shell.ShellConnector.readControlData(ShellConnector.java:191)
at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:186)
at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
at java.lang.Thread.run(Thread.java:818)
 
Last edited:

Ivica Golubovic

Active Member
Licensed User
Hi @Ivica Golubovic, you know because initializing JSInterface inside a Class this way fails?
B4X:
JSInterface.Initialize(Me)

I still search to port this @stevel05 library to B4A but compilation crashes on this line.
https://www.b4x.com/android/forum/threads/codemirror-wrapper-and-example.125775/

Log do not help, just says: Error occurred on line: 147 (CodeMirrorWrapper)

Many Thanks

Here the filtered log, for sure you are better than me to know it.
Please share the part of code, I am not sure that I unerstand you...
 

max123

Well-Known Member
Licensed User
Longtime User
Thanks for reply,

maybe I found a mistake, I used this line in the DesignerCreateView where @stevel05 initialized a B4J Javascript using JavaObject and webEngine. Maybe don't like it?

What I do not know is because the UltimateWebView can be initialized with Me but JSInterface no.

Here a relevant code...
If you need I can send all class.

Many thanks

B4X:
In Class_Globals:  Public JSInterface As UltimateJavascriptInterface

Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)

    mBase = Base
    Tag = mBase.Tag
 
    'Initial Values
    mWidth = mBase.Width
    mHeight = mBase.Height

    mBase.LoadLayout("codemirrorwrapper")
 
    mBase.Tag = Me
 
    ''''''''''''''''''''''''''''' SETUP B4J JS '''''''''''''''''''''''''''''''
''''''''''''    WebE = WebEngine_Static.New(WebView1)
 
''''''''''''    WebE.SetOnAlert(Me,"JSAlert")
''''''''''''    WebE.SetOnError(Me,"JSError")
 
'''''''    B4xCalls.Initialize
'''''''    RegisterB4XCall("JsLog",Me,"Js_Log")
'''''''    RegisterB4XCall("codechanged",mCallBack,mEventName & "_CodeChanged")
 
''''''''''    WebE.AddWorkerListener(Me,"LoadProgress")
    ''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''' SETUP B4A JS ''''''''''''''''''''''''''''''''''''
    UltimateWebView1.Initialize(Me, "UltimateWebView1")
'    UltimateWebView1.SetWebViewClient(True) 'Sets WebViewClient and its Events.
    UltimateWebView1.SetWebChromeClient(True) 'Sets WebChromeClient and its Events.
 
    'Other UltimateWebViewSettings
    UltimateWebView1.Settings.JavaScriptEnabled = True
    UltimateWebView1.Settings.JavaScriptCanOpenWindowsAutomatically = True
    UltimateWebView1.Settings.DisplayZoomControls = False
 
'    UltimateWebView1.Settings.AllowContentAccess = True
'    UltimateWebView1.Settings.AllowFileAccess = True
'    UltimateWebView1.Settings.AppCacheEnabled = True
'    UltimateWebView1.Settings.CacheMode = UltimateWebView1.Settings.Constants.CACHEMODE_LOAD_DEFAULT
'    UltimateWebView1.Settings.DomStorageEnabled = True
'    UltimateWebView1.Settings.MediaPlaybackRequiresUserGesture = False
'    UltimateWebView1.Settings.AllowFileAccessFromFileURLs = True
'    UltimateWebView1.Settings.AllowUniversalAccessFromFileURLs = True
'    UltimateWebView1.SetDownloadListener 'Sets and start DownloadListener'
 
    Log("InitMe=" & Me)
 
    JSInterface.Initialize(Me)   ' <<<<<<<  ERROR HERE
    '"B4A" is name of javascriptinterface. You can use different name if you want.
    UltimateWebView1.AddJavascriptInterface(JSInterface, "B4A")
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
 
Last edited:

Ivica Golubovic

Active Member
Licensed User
Thanks for reply,

maybe I found a mistake, I used this line in the DesignerCreateView where @stevel05 initialized a B4J Javascript using JavaObject and webEngine. Maybe don't like it?

Here a relevant code... What I do not know is because the UltimateWebView can be initialized with Me but JSInterface no.
If you need I can send all class.

Many thanks

B4X:
In Class_Globals:  Public JSInterface As UltimateJavascriptInterface

Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)

    mBase = Base
    Tag = mBase.Tag
 
    'Initial Values
    mWidth = mBase.Width
    mHeight = mBase.Height

    mBase.LoadLayout("codemirrorwrapper")
 
    mBase.Tag = Me
 
    ''''''''''''''''''''''''''''' SETUP B4J JS '''''''''''''''''''''''''''''''
''''''''''''    WebE = WebEngine_Static.New(WebView1)
 
''''''''''''    WebE.SetOnAlert(Me,"JSAlert")
''''''''''''    WebE.SetOnError(Me,"JSError")
 
'''''''    B4xCalls.Initialize
'''''''    RegisterB4XCall("JsLog",Me,"Js_Log")
'''''''    RegisterB4XCall("codechanged",mCallBack,mEventName & "_CodeChanged")
 
''''''''''    WebE.AddWorkerListener(Me,"LoadProgress")
    ''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''' SETUP B4A JS ''''''''''''''''''''''''''''''''''''
    UltimateWebView1.Initialize(Me, "UltimateWebView1")
'    UltimateWebView1.SetWebViewClient(True) 'Sets WebViewClient and its Events.
    UltimateWebView1.SetWebChromeClient(True) 'Sets WebChromeClient and its Events.
 
    'Other UltimateWebViewSettings
    UltimateWebView1.Settings.JavaScriptEnabled = True
    UltimateWebView1.Settings.JavaScriptCanOpenWindowsAutomatically = True
    UltimateWebView1.Settings.DisplayZoomControls = False
 
'    UltimateWebView1.Settings.AllowContentAccess = True
'    UltimateWebView1.Settings.AllowFileAccess = True
'    UltimateWebView1.Settings.AppCacheEnabled = True
'    UltimateWebView1.Settings.CacheMode = UltimateWebView1.Settings.Constants.CACHEMODE_LOAD_DEFAULT
'    UltimateWebView1.Settings.DomStorageEnabled = True
'    UltimateWebView1.Settings.MediaPlaybackRequiresUserGesture = False
'    UltimateWebView1.Settings.AllowFileAccessFromFileURLs = True
'    UltimateWebView1.Settings.AllowUniversalAccessFromFileURLs = True
'    UltimateWebView1.SetDownloadListener 'Sets and start DownloadListener'
 
    Log("InitMe=" & Me)
 
    JSInterface.Initialize(Me)   ' <<<<<<<  ERROR HERE
    '"B4A" is name of javascriptinterface. You can use different name if you want.
    UltimateWebView1.AddJavascriptInterface(JSInterface, "B4A")
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
First try not to initialize JSInterface to Designer sub. If that doesn't work, let me know so I can check the library code tomorrow.
 

max123

Well-Known Member
Licensed User
Longtime User
Sorry, I don't known it, what is Designer sub ?

Maybe you intend inside a class initializer ?
B4X:
Public Sub Initialize (Callback As Object, EventName As String)
 
Top