B4A Library WebViewExtras

Mousa Najafi

Member
Licensed User
Longtime User
I added webview to viewpager panel that showed correctly on android 4.2 but blank on android 5
I don't know this relates to webview or something else. I also tried with the webviewextra 1.42
and webviewextra 2 too
 

warwound

Expert
Licensed User
Longtime User
1) Is the WebView blank if you make the page it is contained in into the page that ViewPager initially displays?

2) You can call a ViewPager method named 'setOffscreenPageLimit'.
This sets how many offscreen pages ViewPager will keep loaded in memory.
It might be that your page containing the WebView is being destroyed when offscreen, then when that page becomes visible the WebView fails to be recreated.
So try calling setOffscreenPageLimit and setting a number of pages that will ensure that the page that contains the WebView is always kept in memory.
https://www.b4x.com/android/forum/t...-panels-now-perfect.14165/page-15#post-196173
 

Mousa Najafi

Member
Licensed User
Longtime User
1) I used AHViewPager to design a 4 fixedtab layout. 3 Tabs are simple WebViews added to viewpager's panel and 4th tab
is customlistview that contains cardviews including label and iconbutton.
I got the PageFinished (Url As String) message from webview and it loads webpage from url in android 4.2
but in android 5 It completes loading and just I can scroll down a blank webpage which scroll height is as same as contents of webpage . It seems contents are not able to load.

2)I will try and reply here.
also I will try the AHViewPager updated library ( DesignSupport) as I think this problem should be related to deprecated
AHViewPager library
 

Mousa Najafi

Member
Licensed User
Longtime User
The problem is with website. I made a simple test webview which loads every tested webpage except my links. links works in a
browser in my device. also another demo app that developed in android studio.
I enabled javascript and setwebchromeclient by looking the source code from android studio project but I couldn't succeed
would you test the following link in a webview and see what's going wrong with this web page in android 5.0
link:
http://pushe.co/mcontact/
 

Mousa Najafi

Member
Licensed User
Longtime User
by the way. here is my tested source code:
B4X:
Sub Globals
    Dim WebView1 As WebView
    Dim client As DefaultWebChromeClient
    Dim murl As String = "http://pushe.co/mcontact/"
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
  
    Activity.LoadLayout("WebView")
  
    Dim webextra As WebViewExtras
  
    webextra.Initialize(WebView1)
    client.Initialize("geo")
    webextra.GetSettings.SetCacheMode(webextra.GetSettings.LOAD_CACHE_ELSE_NETWORK)
    webextra.ZoomEnabled = True
    webextra.SetWebChromeClient(client)
   
    webextra.JavaScriptEnabled = True
    WebView1.LoadUrl(murl)
End Sub
 
Last edited:

Mousa Najafi

Member
Licensed User
Longtime User
I attached the fragment xml and java code that is working properly for the above link.
project is in android studio.
 

Attachments

  • fragment.zip
    1.5 KB · Views: 334

stevel05

Expert
Licensed User
Longtime User
There appears to be something in the Javascript that the webview doesn't like on that site, if you add the lines:

B4X:
    Dim WVJO As JavaObject = WebView1
    WVJO.RunMethod("setWebContentsDebuggingEnabled",Array(True))

You can then use the chrome debugging tools on a USB connected Android device at chrome://inspect/#devices in a Google Chrome Browser on your PC to access a huge amount of debugging information.

More info here: https://developers.google.com/web/t...debug/remote-debugging/remote-debugging?hl=en
 

warwound

Expert
Licensed User
Longtime User
Well i'm busy working for the next three days and then i'm flying to the UK on Thursday.
I won't have time to look at the problem until after christmas .
 

warwound

Expert
Licensed User
Longtime User
HELP!! Open camera for input type file in Webview not opening

WebViewExtras really needs an update to handle all the changes made in the WebView since KitKat and later.
As well as 'camera input', the 'file upload' feature needs updating.

Unfortunately i don't have the time to make such an update.
I can make the source code available if anyone else wants to attempt an update...
 

MetalOS

Member
Licensed User
Longtime User
Hello,

I started on Basic4Android and I would load in a WebView a geolocated map Leaflet project. Only when using your library WebViewExtras 1.42, the WebView stays white and nothing is displayed. I do my testing on a Samsung Galaxy S4 on CyanogenMod 13 (Android 6.0.1). Thank you for your help.

I joined you an example code that I use for testing:
 

Attachments

  • GeoLeaflet.zip
    7.8 KB · Views: 403

MarcoRome

Expert
Licensed User
Longtime User
Hi All. I have this page in website:



Now with this code, i can username and password and enter in the site.


B4X:
....
Sub WebView1_PageFinished (Url As String)
    If(CookieManager1.HasCookies) Then
      Log("Cookies: "&CookieManager1.GetCookie(Url))
   Else
      Log("No cookies found")
   End If

    Log("WebView1_PageFinished")
    If Url=LogonUrl Then
             Dim Javascript As StringBuilder
            Javascript.Initialize
            Javascript.Append("var form=document.forms[0];")   '   this assumes your form is the first form on the page
           
            Javascript.Append("form.log.value='"& Starter.user &"';")
            Javascript.Append("form.pwd.value='"& Starter.password &"';")
            Javascript.Append("form.submit()")
            Log("Executing javascript: "&Javascript.ToString)
        '    uncomment next line to auto submit the logon form
        '    be careful - if logon fails then the webpage will be reloaded
        '    and an infinite loop of failed logons is likely
        '    Javascript.Append("document.forms.fSSUser_Logon.submit();")
        WebViewExtras1.ExecuteJavascript(Javascript.ToString)
        Log("Form updated")
 
    End If
End Sub

Now the question is, can i in my code write as if user click about link "Registrati Ora" ( as in picture ) ??

is source page i have this:
<p style="text-align:center; margin-top:20px;"><strong><a href="javascript:void(0);" id="new-tl" class="under-login">Registrati Ora »</a></strong></p>

Thank you all
Marco
 

An Schi

Well-Known Member
Licensed User
Is webviewextras2 compatible with all versions of android?

It is running fine on my S4 with 5.0.1
In Genymotion it is running fine on a 4.1
But running it in Genymotion with 2.3.7 it crashes and in the logs are some strange things.

In the manifest i have minsdk = 9 and targetsdk = 21.

Right now i don't have time to look more at the logs or do more testing, so my question is:
Is this library supposed to work with all android versions?
 
Last edited:

An Schi

Well-Known Member
Licensed User
Worth posting the error messages.

I'll do in the evening when i am back at home.
From memory it was something like "cannot find ressource martinpearman (blabla) webkit (blabla)" several times with different endings (if that helps...).



Maybe it is irrelevant. I'd like to know if the library, and therefore my app, works on that anyway. Especially i would like to know what the minsdk is when i use this library.


Why are you setting maxSdk?

This was just a writing error. In my manifest i use targetsdk = 21 of course. (I've corrected the original post)
 

An Schi

Well-Known Member
Licensed User
Below is the full unfiltered log.
Please don't forget that this is running a Samsung Galaxy S2, Android 2.3.7 with Genymotion.

B4X:
>>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
CheckJNI is OFF
Calling main entry com.android.commands.pm.Pm
Start proc com.android.defcontainer for service com.android.defcontainer/.DefaultContainerService: pid=507 uid=10018 gids={1015, 2001}
GC_EXPLICIT freed 281K, 51% free 2684K/5447K, external 1625K/2137K, paused 24ms
No content provider found for:
No content provider found for:
Scanning package: /data/app/vmdl1332398406.tmp
Scanning package anschi.byhtest
Unpacking native libraries for /data/app/anschi.byhtest-1.apk
DexInv: --- BEGIN '/data/app/anschi.byhtest-1.apk' ---
DexOpt: load 20ms, verify+opt 204ms
DexInv: --- END '/data/app/anschi.byhtest-1.apk' (success) ---
  Services: anywheresoftware.b4a.samples.httputils2.httputils2service
  Receivers: anywheresoftware.b4a.samples.httputils2.httputils2service$httputils2service_BR
  Activities: anschi.byhtest.main
Force stopping package anschi.byhtest uid=10027
move /data/dalvik-cache/data@app@anschi.byhtest-1.apk@classes.dex -> /data/dalvik-cache/data@app@anschi.byhtest-1.apk@classes.dex
New package installed in /data/app/anschi.byhtest-1.apk
Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=516 uid=10006 gids={}
no available voice recognition services found
GC_EXPLICIT freed 1030K, 47% free 4136K/7687K, external 4378K/7378K, paused 42msShutting down VM
GC_CONCURRENT freed 98K, 72% free 290K/1024K, external 0K/0K, paused 0ms+0ms
adbd disconnected
Pub com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.CorporaUpdateReceiver: pid=525 uid=10003 gids={3003}
Pub com.android.quicksearchbox.google: com.android.quicksearchbox.google.GoogleSuggestionProvider
Pub com.android.quicksearchbox.shortcuts: com.android.quicksearchbox.ShortcutsProvider
>>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
CheckJNI is OFF
Calling main entry com.android.commands.am.Am
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=anschi.byhtest/.main } from pid 535
Start proc anschi.byhtest for activity anschi.byhtest/.main: pid=542 uid=10027 gids={3003}
HostConnection::get() New Host Connection established 0x96f0360, tid 212
Shutting down VM
GC_CONCURRENT freed 99K, 70% free 314K/1024K, external 0K/0K, paused 1ms+0ms
adbd disconnected
Could not find method android.view.ViewGroup.addChildrenForAccessibility, referenced from method anywheresoftware.b4a.BALayout.addChildrenForAccessibility
VFY: unable to resolve virtual method 316: Landroid/view/ViewGroup;.addChildrenForAccessibility (Ljava/util/ArrayList;)V
VFY: replacing opcode 0x6f at 0x0005
VFY: dead code 0x0008-0008 in Lanywheresoftware/b4a/BALayout;.addChildrenForAccessibility (Ljava/util/ArrayList;)V
Could not find method android.view.View.setPivotX, referenced from method anywheresoftware.b4a.objects.ViewWrapper.AnimateFrom
VFY: unable to resolve virtual method 310: Landroid/view/View;.setPivotX (F)V
VFY: replacing opcode 0x6e at 0x0013
VFY: dead code 0x0016-00bf in Lanywheresoftware/b4a/objects/ViewWrapper;.AnimateFrom (Landroid/view/View;IIIII)V
VFY: dead code 0x00c1-00c3 in Lanywheresoftware/b4a/objects/ViewWrapper;.AnimateFrom (Landroid/view/View;IIIII)V
Could not find method android.animation.ValueAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.ViewWrapper.SetColorAnimated
VFY: unable to resolve static method 12: Landroid/animation/ValueAnimator;.ofFloat ([F)Landroid/animation/ValueAnimator;
VFY: replacing opcode 0x71 at 0x0033
VFY: dead code 0x0036-0050 in Lanywheresoftware/b4a/objects/ViewWrapper;.SetColorAnimated (III)V
Could not find method android.animation.ObjectAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.ViewWrapper.SetVisibleAnimated
VFY: unable to resolve static method 7: Landroid/animation/ObjectAnimator;.ofFloat (Ljava/lang/Object;Ljava/lang/String;[F)Landroid/animation/ObjectAnimator;
VFY: replacing opcode 0x71 at 0x001f
Could not find method android.animation.ObjectAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.ViewWrapper.SetVisibleAnimated
VFY: unable to resolve static method 7: Landroid/animation/ObjectAnimator;.ofFloat (Ljava/lang/Object;Ljava/lang/String;[F)Landroid/animation/ObjectAnimator;
VFY: replacing opcode 0x71 at 0x0041
VFY: dead code 0x0022-0039 in Lanywheresoftware/b4a/objects/ViewWrapper;.SetVisibleAnimated (IZ)V
VFY: dead code 0x0044-0045 in Lanywheresoftware/b4a/objects/ViewWrapper;.SetVisibleAnimated (IZ)V
Could not find method android.animation.ObjectAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.PanelWrapper.SetElevationAnimated
VFY: unable to resolve static method 7: Landroid/animation/ObjectAnimator;.ofFloat (Ljava/lang/Object;Ljava/lang/String;[F)Landroid/animation/ObjectAnimator;
VFY: replacing opcode 0x71 at 0x001f
VFY: dead code 0x0022-002a in Lanywheresoftware/b4a/objects/PanelWrapper;.SetElevationAnimated (IF)V
Could not find method android.animation.ValueAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.TextViewWrapper.SetTextColorAnimated
VFY: unable to resolve static method 12: Landroid/animation/ValueAnimator;.ofFloat ([F)Landroid/animation/ValueAnimator;
VFY: replacing opcode 0x71 at 0x0023
VFY: dead code 0x0026-0040 in Lanywheresoftware/b4a/objects/TextViewWrapper;.SetTextColorAnimated (II)V
Could not find method android.animation.ObjectAnimator.ofFloat, referenced from method anywheresoftware.b4a.objects.TextViewWrapper.SetTextSizeAnimated
VFY: unable to resolve static method 7: Landroid/animation/ObjectAnimator;.ofFloat (Ljava/lang/Object;Ljava/lang/String;[F)Landroid/animation/ObjectAnimator;
VFY: replacing opcode 0x71 at 0x001d
VFY: dead code 0x0020-0028 in Lanywheresoftware/b4a/objects/TextViewWrapper;.SetTextSizeAnimated (IF)V
Could not find method android.webkit.WebView.canZoomIn, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.CanZoomIn
VFY: unable to resolve virtual method 464: Landroid/webkit/WebView;.canZoomIn ()Z
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-000a in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.CanZoomIn ()Z
Could not find method android.webkit.WebView.canZoomOut, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.CanZoomOut
VFY: unable to resolve virtual method 465: Landroid/webkit/WebView;.canZoomOut ()Z
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-000a in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.CanZoomOut ()Z
Could not find method android.webkit.WebView.evaluateJavascript, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.ExecuteJavascript
VFY: unable to resolve virtual method 472: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V
VFY: replacing opcode 0x6e at 0x000d
Could not find method android.webkit.WebView.findAllAsync, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.FindAllAsynch
VFY: unable to resolve virtual method 474: Landroid/webkit/WebView;.findAllAsync (Ljava/lang/String;)V
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-0009 in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.FindAllAsynch (Ljava/lang/String;)V
Could not find method android.webkit.WebView.isPrivateBrowsingEnabled, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.IsPrivateBrowsingEnabled
VFY: unable to resolve virtual method 491: Landroid/webkit/WebView;.isPrivateBrowsingEnabled ()Z
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-000a in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.IsPrivateBrowsingEnabled ()Z
Could not find method android.webkit.WebView.removeJavascriptInterface, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.RemoveJavascriptInterface
VFY: unable to resolve virtual method 502: Landroid/webkit/WebView;.removeJavascriptInterface (Ljava/lang/String;)V
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-0009 in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.RemoveJavascriptInterface (Ljava/lang/String;)V
Could not find method android.webkit.WebView.saveWebArchive, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.SaveWebArchive
VFY: unable to resolve virtual method 505: Landroid/webkit/WebView;.saveWebArchive (Ljava/lang/String;)V
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-0009 in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.SaveWebArchive (Ljava/lang/String;)V
Could not find method android.webkit.WebView.setFindListener, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.SetFindListener
VFY: unable to resolve virtual method 506: Landroid/webkit/WebView;.setFindListener (Landroid/webkit/WebView$FindListener;)V
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-0009 in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.SetFindListener (Landroid/webkit/WebView$FindListener;)V
Could not find method android.webkit.WebView.showFindDialog, referenced from method uk.co.martinpearman.b4a.webkit.WebViewExtras.ShowFindDialog
VFY: unable to resolve virtual method 517: Landroid/webkit/WebView;.showFindDialog (Ljava/lang/String;Z)Z
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-000a in Luk/co/martinpearman/b4a/webkit/WebViewExtras;.ShowFindDialog (Ljava/lang/String;Z)Z
** Activity (main) Create, isFirst = true **
Could not find class 'android.webkit.WebResourceResponse', referenced from method uk.co.martinpearman.b4a.webkit.DefaultWebViewClient$1.shouldInterceptRequest
VFY: unable to resolve check-cast 136 (Landroid/webkit/WebResourceResponse;) in Luk/co/martinpearman/b4a/webkit/DefaultWebViewClient$1;
VFY: replacing opcode 0x1f at 0x0045
VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
** Activity (main) Resume **
HostConnection::get() New Host Connection established 0x96f6a40, tid 542
Displayed anschi.byhtest/.main: +2s339ms
** Service (httputils2service) Create **
request time failed: java.net.SocketTimeoutException: Try again
** Service (httputils2service) Start **
WebViewClient1_PageStarted. URL= http://www.XXXXXXXXXXXXXXXXXXXXXXX
VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
VFY: unable to resolve static method 4427: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
VFY: replacing opcode 0x71 at 0x000a
VFY: dead code 0x000d-0012 in Lokio/Okio;.sink (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Lokio/Sink;
VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
VFY: unable to resolve static method 4426: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
VFY: replacing opcode 0x71 at 0x000a
VFY: dead code 0x000d-0012 in Lokio/Okio;.source (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Lokio/Source;
WebViewClient1_PageStarted. URL= http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GC_CONCURRENT freed 748K, 49% free 3443K/6727K, external 2107K/2137K, paused 1ms+2ms
GC_CONCURRENT freed 577K, 46% free 3749K/6855K, external 2107K/2137K, paused 1ms+9ms
GC_EXPLICIT freed 71K, 49% free 2884K/5639K, external 5397K/6562K, paused 15ms
WebViewClient1_PageStarted. URL= http://www.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
WebViewClient1_PageStarted. URL= http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Process anschi.byhtest (pid 542) has died.
Scheduling restart of crashed service anschi.byhtest/anywheresoftware.b4a.samples.httputils2.httputils2service in 5000ms
WIN DEATH: Window{b66c9170 anschi.byhtest/anschi.byhtest.main paused=false}
Process 542 terminated by signal (11)
Got RemoteException sending setActive(false) notification to pid 542 uid 10027
 

warwound

Expert
Licensed User
Longtime User
Look at the android WebView documentation, look at the documentation for methods which are mentioned in your errors.
For example canZoomIn.
See this method was added to the WebView in android API level 11?
API level 11 is android 3.0.x so this method is not available on your android 2.3 device.

I'd guess the same applies to the other methods mentioned in your errors - i haven't got time to check though.
 

An Schi

Well-Known Member
Licensed User
I made this summary of the webview and defaultwebviewclient errors from above logs.
Two things here are strange to me: First i don't use any of the things in my code (like canZoomIn or setFindListener). Second strange thing is that 'WebResourceResponse' was added in API level 21, which is Android 5.0, but i don't get this errors when i run Genymotion with Android 4.1.

Could not find method android.webkit.WebView.canZoomIn -> Added in API 11
Could not find method android.webkit.WebView.canZoomOut -> Added in API 11
Could not find method android.webkit.WebView.evaluateJavascript -> Added in API 19
Could not find method android.webkit.WebView.findAllAsync -> Added in API 16
Could not find method android.webkit.WebView.isPrivateBrowsingEnabled -> Added in API 11
Could not find method android.webkit.WebView.removeJavascriptInterface -> Added in API 11
Could not find method android.webkit.WebView.saveWebArchive -> Added in API 11
Could not find method android.webkit.WebView.setFindListener -> Added in API 16
Could not find method android.webkit.WebView.showFindDialog -> Added in API 11
Could not find class 'android.webkit.WebResourceResponse' -> Added in API 21
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…