B4A Library WebkitLibrariesSet (successor to UltimateWebView)

IMPORTANT!!!
Library deprecated. Use UltimateWebView2 instead.

WebkitLibrariesSet is an advanced successor to the UltimateWebView library. Instead of a single library that made up UltimateWebView, the new concept contains a collection of a large number of libraries that belong to the android.webkit class set. Each library that is an integral part of the WebkitLibrariesSet contains from one to at most several smaller classes.

The advantages of this approach are multiple, and I will mention only a part of them:
  • Each library in the set is independent from the others, but can be used in synergy with each of the libraries in the set.
  • For your project, you will use only those libraries from the kit that are needed for your project. With this approach, you can reduce the size of your final application compared to the size of the application using a single UltimateWebView library.
  • In addition to the fact that each library in the kit is independent, each of them can be used with the native B4A WebView. This means that if you do not need to use WebkitWebView (successor of UltimateWebView) with all its options, in that case you can use native WebView in synergy with other libraries in this set.
  • To use WebkitWebView Custom View (the successor of UltimateWebView), you don't have to use all the libraries from set, but only those that are necessary for your project (while using UltimateWebView all classes from the set of libraries were necessary).
Over time, this set of libraries will be upgraded with new libraries that will contain classes from the android.webkit class set. Also, these new libraries will be independent to use from other libraries in the kit and all will be able to be used with native B4A WebView.

Manifest requirements:
  • For WebkitWebChromeClient
    • Manifest:
      'Camera Permissions
      AddPermission(android.permission.CAMERA)
      AddPermission(android.permission.RECORD_AUDIO)
      AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
      AddPermission(android.permission.MICROPHONE)
      '------------------------
      
      '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)
      '------------------------
  • For WebkitDownloadListener
    • Manifest:
      'DownloadListener Permissions
      AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
      '------------------------
  • For WebkitWebView Custom View.
    • Manifest:
      SetApplicationAttribute(android:usesCleartextTraffic,"true")
In the manifest, add lines that are necessary for your project, do not add unnecessary ones.

Version 1.0
libraries list:
  1. WebkitConsoleMessage 1.0
  2. WebkitCookieManager 1.0
  3. WebkitDownloadListener 1.0
  4. WebkitHttpAuthHandler 1.0
  5. WebkitJavascriptInterface 1.0
  6. WebkitJsResultAndJsPromptResult 1.0
  7. WebkitMimeTypeMap 1.0
  8. WebkitSafeBrowsingResponse 1.0
  9. WebkitURLUtil 1.0
  10. WebkitWebBackForwardList 1.0
  11. WebkitWebChromeClient 1.0
  12. WebkitWebResourceError 1.0
  13. WebkitWebResourceRequest 1.0
  14. WebkitWebResourceResponse 1.0
  15. WebkitWebView 1.0 Custom View
  16. WebkitWebViewAssetLoader 1.0
  17. WebkitWebViewClient 1.0
  18. WebkitWebViewDatabase 1.0
  19. WebkitWebViewSettings 1.0

If this libraries makes your work easier and saves time in creating your application, please make a donation.
 

Attachments

  • WebkitLibrariesSet_1.0_doc.rar
    30.4 KB · Views: 882
  • WebkitLibrariesSet_1.0_lib.zip
    143 KB · Views: 899
Last edited:
getRequestHeaders:
abstract fun getRequestHeaders(): MutableMap<String!, String!>!
java sample:
APIRequest apiRequest = AppRegistryBridge.getJSONInstance().create().fromJson(request.getRequestHeaders().get("Content-Body"), APIRequest.class);
B4X:
    Dim m As Map = Request.RequestHeaders
    For Each k As Object In m.Keys
        Log(k & ": " & m.Get(k))
    Next
java.lang.RuntimeException: method not supported. Use For Each instead.
 
Dear Ivica Golubovic!, Can you implement this or guide how to use it instead WebkitWebChromeClient??
 

Ivica Golubovic

Active Member
Licensed User
I'm sorry you think that way ?
While this request is a basic requirement for better performance and fixing the defects of this library that you have worked hard for
Okay, I don't mean to be rude, but do you really think I don't have other things to do for a living. If I write to you that I don't have time to deal with it right now, why do you give me moral advice? That doesn't mean I won't tackle it at some point in the future, but right now I'm too busy with business commitments. If you had listened to me and shared your problem with other forum members, you might have had an alternative solution to your problem by now. You can use JavaObject to solve the problem with request headers, but if you don't know how to achieve it, please post a new forum post and other members will surely help you. You can use Request.ToObject to get a pure java WebResourceRequest and then through JavaObject to get the solution to your problem.
 
Thank you very much for taking the time to answer me
 

Thalia

Member
Dear Ivica Golubovic!, Can you implement this or guide how to use it instead WebkitWebChromeClient??
I would also like to know the correct way to implement a Chrome client with this library, or a simple example of how to use it (no web page appears when I try to start it).
 

Ivica Golubovic

Active Member
Licensed User
I would also like to know the correct way to implement a Chrome client with this library, or a simple example of how to use it (no web page appears when I try to start it).
WebChromeClient is part of the Webkit set of libraries and is used as a plugin for the native WebView. It cannot be used as a Chrome browser. You have to add the webview object and then initialize the WebChromeClient where you pass the WebView as a parameter.
 

Thalia

Member
Thanks. Do you have an little example of how to use not webview, only the library?. I try to make a simple webview (without ChromeClient) and my webview (added in the designer) dont show me nothing (the webview looks transparent). Thanks so much.
 

amer kasem

Member
Licensed User
What is the benefit of this huge library and all these efforts without a single example, it seems that no one have a clue about how to run this thing
 

Ivica Golubovic

Active Member
Licensed User
What is the benefit of this huge library and all these efforts without a single example, it seems that no one have a clue about how to run this thing
Maybe you don't know, and the others at least try to find out. It would be best to make the exact example you need. If you had opened the documentation and looked a little at how the WebKit class set works, maybe it would be clear to you. And if ten examples were made, it would not be enough to cover all the possibilities that this library provides. I'll give you one piece of advice, spend some time looking through the documentation and searching the internet because no one will do it for you.
 

amer bashar

Member
Licensed User
read other comments
 

dennmtr

Member
Licensed User
You can't update UI from ShouldInterceptRequest2 Event (and other events). You can't directly call Subs too. The only way to call an activity sub inside this method is to call it using CallSubDelayed even is in the same (active) activity or else you have a wrong Thread error.

Except from that i always have to set WebView page to about:blank before activity pauses (and wait for PageFinished Event) becauses the application crashes with webview error alert (messagebox from os) without any exception details thrown. Not that tricky, and many times doesn't work, because you cant wait for an event inside the activity pause event, you have to change page to about:blank every time you manually change activity, press key event, but you cant do this if you press home button for example or when screen blanks. Same happens even if i have ShouldInterceptRequest2 and any webkit event commented out from code

The error message:
"Uninstall WebView updates? The installed version of WebView caused application to crash. Uninstall the WebView updates, then restart application. CANCEL, UNINSTALL"

ShouldInterceptRequest2 is a very very cool thing, does b4i support interception too?

Edit:

Once WebViewClient Or ChromeClient are disabled (set enabled to false) there is no way to enable them back again setting enabled to true. even setting to true no event triggered again (you know, toggle between activity resume and pause)
 
Last edited:

kofiking

Member
Thank you for creating a great library. After researching for a while, I found it very useful, but I found some bugs.
In Android 7.1.2, all events in WebkitWebViewClient are unresponsive. If webview is used together with WebkitWebViewClient, WebkitWebViewClient cannot initialize with error: "java.lang.RuntimeException: Method: getWebViewClient not found in: android.webkit.WebView"。 I have found a solution to the problem and cannot solve it myself. Can you help me fix it?
Also, could you help add this feature? WebView HitTestResult or how to use HitTestResult, thank you!
 

Ivica Golubovic

Active Member
Licensed User
I am aware of the problem you mentioned. The problem is that this library requires the getWebViewClient and getWebChroneClient methods in order to work with the native B4A WebView. The process of reworking the library is in progress, i.e. creating a clone of this library in Eclipse. After that, it will be possible to overcome the above mentioned problems. I hope it will be ready in a few weeks. For now it is possible to use the library for Api 26 and above.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…