B4A Library AdvancedWebview

this is a wrap for this github project.

Enhanced WebView component for Android that works as intended out of the box

AdvancedWebview
Author:
DonManfred (wrapper)
Version: 1
AdvancedWebView
Events:

  • onPageError (errorCode As Int, description As String, failingUrl As String)
  • onPageStarted (url As String, favIcon As Object)
  • onDownloadRequested (url As String, suggestedFilename As String, mimeType As String, contentLength As long, contentDisposition As String, userAgent As String)
  • onPageFinished (url As String)
  • onExternalPageRequest (url As String)
Fields:
  • ba As anywheresoftware.b4a.BA
Methods:
  • DesignerCreateView (base As anywheresoftware.b4a.objects.PanelWrapper, lw As anywheresoftware.b4a.objects.LabelWrapper, props As anywheresoftware.b4a.objects.collections.Map) As void
  • clearPermittedHostnames As void
  • onPause As void
  • handleDownload (fromUrl As java.lang.String, toFilename As java.lang.String) As boolean
    Handles a download by loading the file from `fromUrl` and saving it to `toFilename` on the external storage

    This requires the two permissions `android.permission.INTERNET` and `android.permission.WRITE_EXTERNAL_STORAGE`

    Only supported on API level 9 (Android 2.3) and above
    context: a valid `Context` reference
    fromUrl: the URL of the file to download, e.g. the one from `AdvancedWebView.onDownloadRequested(...)`
    toFilename: the name of the destination file where the download should be saved, e.g. `myImage.jpg`
    Return type: @return:whether the download has been successfully handled or not
  • IsInitialized As boolean
  • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
  • loadHtml (html As java.lang.String) As void
    Loads and displays the provided HTML source text
    html: the HTML source text to load
  • addHttpHeader (name As java.lang.String, value As java.lang.String) As void
    Adds an additional HTTP header that will be sent along with every HTTP `GET` request

    This does only affect the main requests, not the requests to included resources (e.g. images)

    If you later want to delete an HTTP header that was previously added this way, call `removeHttpHeader()`

    The `WebView` implementation may in some cases overwrite headers that you set or unset
    name: the name of the HTTP header to add
    value: the value of the HTTP header to send
  • BringToFront As void
  • SetLayout (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • removePermittedHostname (hostname As java.lang.String) As void
  • SendToBack As void
  • addPermittedHostnames (collection As java.util.Collection) As void
  • onBackPressed As boolean
  • SetVisibleAnimated (arg0 As int, arg1 As boolean) As void
  • onDestroy As void
  • RemoveView As void
  • Invalidate3 (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • Invalidate2 (arg0 As android.graphics.Rect) As void
  • SetColorAnimated (arg0 As int, arg1 As int, arg2 As int) As void
  • loadUrl2 (url As java.lang.String, preventCaching As boolean) As void
  • loadHtml4 (html As java.lang.String, baseUrl As java.lang.String, historyUrl As java.lang.String, encoding As java.lang.String) As void
    Loads and displays the provided HTML source text
    html: the HTML source text to load
    baseUrl: the URL to use as the page's base URL
    historyUrl: the URL to use for the page's history entry
    encoding: the encoding or charset of the HTML source text
  • isFileUploadAvailable As boolean
    Returns whether file uploads can be used on the current device (generally all platform versions except for 4.4)
    Return type: @return:whether file uploads can be used
  • SetBackgroundImage (arg0 As android.graphics.Bitmap) As void
  • loadHtml3 (html As java.lang.String, baseUrl As java.lang.String, historyUrl As java.lang.String) As void
    Loads and displays the provided HTML source text
    html: the HTML source text to load
    baseUrl: the URL to use as the page's base URL
    historyUrl: the URL to use for the page's history entry
  • loadHtml2 (html As java.lang.String, baseUrl As java.lang.String) As void
    Loads and displays the provided HTML source text
    html: the HTML source text to load
    baseUrl: the URL to use as the page's base URL
  • onResume As void
  • loadUrl (url As java.lang.String) As void
  • Invalidate As void
  • addPermittedHostname (hostname As java.lang.String) As void
  • removeHttpHeader (name As java.lang.String) As void
    Removes one of the HTTP headers that have previously been added via `addHttpHeader()`

    If you want to unset a pre-defined header, set it to an empty string with `addHttpHeader()` instead

    The `WebView` implementation may in some cases overwrite headers that you set or unset
    name: the name of the HTTP header to remove
  • SetLayoutAnimated (arg0 As int, arg1 As int, arg2 As int, arg3 As int, arg4 As int) As void
  • RequestFocus As boolean
Permissions:
  • android.permission.ACCESS_NETWORK_STATE
  • android.permission.INTERNET
  • android.permission.WRITE_EXTERNAL_STORAGE
Properties:
  • Left As int
  • Background As android.graphics.drawable.Drawable
  • Parent As java.lang.Object [read only]
  • ThirdPartyCookiesEnabled As boolean [write only]
  • Color As int [write only]
  • Enabled As boolean
  • PermittedHostnames As java.util.List [read only]
  • MixedContentAllowed As boolean [write only]
  • Top As int
  • CookiesEnabled As boolean [write only]
  • UploadableFileTypes As java.lang.String [write only]
  • WebChromeClient As android.webkit.WebChromeClient [write only]
  • Visible As boolean
  • Padding As int[]
  • Height As int
  • Tag As java.lang.Object
  • Width As int
  • GeolocationEnabled As boolean [write only]
  • WebViewClient As android.webkit.WebViewClient [write only]
  • DesktopMode As boolean [write only]
 

Attachments

  • AdvancedWebviewV1.0.zip
    21.5 KB · Views: 1,175
  • AdvWebviewEx.zip
    8.1 KB · Views: 1,144

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Why are types in documentation different ? like
  • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
 

DonManfred

Expert
Licensed User
Longtime User
I´m not sure... You dont need to add the parameter... B4A will add this parameter automatically...
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Why in some devices (like mine LG G4 android 6) the webview show empty white page! its content appears if i touch & move the screen !!!!!
 

b4xscripter

Member
Licensed User
Longtime User
Hi,
first of all, many thanks for this amazing library!
I have a question. When the Internet Connection is down, I would not like to have in my app the browser's message "You don't have Internet Connection". I would like to have a message coming from my app, something like "Waiting for Internet Connection, please wait...". Is it possible to manage that from AdvancedWebView?
Thanks!
 

An Schi

Well-Known Member
Licensed User
In the onPageError event, you could hide the webview and display a message by yourself (i think).
 

peacemaker

Expert
Licensed User
Longtime User
Can it upload files to a server via a form?
 

b4xscripter

Member
Licensed User
Longtime User
Ok, ok! I just wanted to research....Thank you, DonManfred for this amazing library! It was really out of box!
 

b4xscripter

Member
Licensed User
Longtime User
Hi,
Do you plan to implement OverrideUrl?

I would like to have the possibility to implement the "share button" option

Best regards

OverrideUrl
 

ferya1

New Member
Licensed User
Longtime User
many thanks
Why full screen video causes to not responding the app?
when I touch full screen everything stops and app not responding.
regards
 
Top