Android Question [B4A] JavaObject InitializeNewInstance

MrSm1Th

Member
Hi , i have a problem with JavaObject
When i InitializeNewInstance , B4A raise me an error : java.lang.ClassNotFoundException: b4a$example$main$MyChromeClient

I Use Thease LIBs in my project : PhoneIntents / WebviewExtras2 / ContentResolver / RunTimePermissions / SQL / JavaObject / Phone / Core

B4X:
Sub Globals
    Private WebView1 As WebView
    Dim wbextra As WebViewExtras
    Dim p As PhoneIntents
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    Dim client As JavaObject
    Dim jo As JavaObject = WebView1
    client.InitializeNewInstance(Application.PackageName & ".main$MyChromeClient",Null)
    jo.RunMethod("setWebChromeClient", Array(client))
    WebView1.LoadUrl("https://SomeUrl.ZzZ")
End Sub


Errors :
B4X:
Error occurred on line: 34 (Main)
java.lang.ClassNotFoundException: b4a$example$main$MyChromeClient
    at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:288)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:83)
    at b4a.example.main.main._activity_create(main.java:416)
    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)
....



Project MIN and Target SDK Version :
android:minSdkVersion="21" android:targetSdkVersion="29"

I Use B4A 10.5 / JDK 11 /
ALL Libraries Jetifired
Also i reinstalled B4A , Android SDK , JDK
But nothing happend

how can i solve this problem ?
[ I'm Beginner ]
Thanks .
 

MrSm1Th

Member
You should tell us where this code come from. I guess that you didn't add the inline Java code.

Ow , you're right Erel .
Thanks a lot , i miss java code section ! šŸ˜¶

----------------------------------------------------

i've one more question ,
i've webview in my project .
i wanna get result status code
for example if url returns 404 , i send toast message " 404 "

i wanna check user internet connection

Thanks
 
Upvote 0
Top