Android Question strange webviewextras2 error

Devv

Active Member
Licensed User
Longtime User
how could this code
B4X:
Sub WebViewClient_PageStarted(Url As String, FavIcon As Bitmap)
    If Url.Contains("&id_universalpay_system=1") Then 'bank muscat payment detected (during checkout)
        ImageView_BankMuscatLogo.SetVisibleAnimated(500, True)
    Else if Url.Contains("&id_universalpay_system=2") Then 'Thawani payment detected (during checkout)
        ImageView_ThawaniLogo.SetVisibleAnimated(500, True)
    Else'hide bank muscat and thawani logo when navigating to another webpage
        If ImageView_BankMuscatLogo.Visible Then ImageView_BankMuscatLogo.SetVisibleAnimated(200, False)
        If ImageView_ThawaniLogo.Visible Then ImageView_ThawaniLogo.SetVisibleAnimated(200, False)
    End If
    
    If Url <> "https://beisat.com/" & Starter.language & "/login?back=my-account" Or Url <> "https://beisat.com/" & Starter.language & "/my-account" Then
        If ImageView_settings.Visible Then ImageView_settings.SetVisibleAnimated(100, False)
    End If
    
    LogColor(Url, Colors.Green)
    
    javascript 'hide header elements and cart items count
End Sub

trigger this error !

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
https://beisat.com/en/
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
com.beisat.android.main:_webviewclient_pagestarted, [https://beisat.com/en/headphones-earphones/49-jbl-everest-wireless-on-ear-headphone-gunmetal.html, android.graphics.Bitmap@115d719]
Error occurred on line: 111 (Main)
java.lang.IllegalArgumentException: method com.beisat.android.main._webviewclient_pagestarted argument 2 has type anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper, got android.graphics.Bitmap
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:352)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at uk.co.martinpearman.b4a.webkit.DefaultWebViewClient$1.onPageStarted(DefaultWebViewClient.java:160)
at In.c(PG:15)
at oD0.handleMessage(PG:77)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
attachBaseContext



note line 111 is
B4X:
Sub WebViewClient_PageStarted(Url As String, FavIcon As Bitmap)


any help is highly appreciated
 

DonManfred

Expert
Licensed User
Longtime User
try
B4X:
Sub WebViewClient_PageStarted(Url As String, FavIcon As Object)
dim ficon as bitmap = FavIcon
' work with ficon
end sub
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
try
B4X:
Sub WebViewClient_PageStarted(Url As String, FavIcon As Object)
dim ficon as bitmap = FavIcon
' work with ficon
end sub

seems to work !

can you please explain why we needed to declare it as an object ?

i was using the event from the documentation , it is by default as bitmap
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
probably because the b4a Bitmap is different to the bitmap Object from Android. B4A Bitmap is a wrapper.
Defining the sub signature as FavIcon As Object takes the parameter (whatever it is).
the next line then creates a wrapperobject and passes the Android Bitmap (encapsulated in the Object).
 
Upvote 0
Top