Hi All. I have this code in B4A ( in B4J work very well )
When run i have this error:
Any idea ?
Thank you
Marco
B4X:
Sub CreateTrustAllSSLSocketFactory As JavaObject
Dim tm As CustomTrustManager
tm.InitializeAcceptAll
Dim SSLContext As JavaObject
SSLContext = SSLContext.InitializeStatic("javax.net.ssl.SSLContext").RunMethod("getInstance", Array("TLS"))
SSLContext.RunMethod("init", Array(Null, tm, Null))
Dim Factory As JavaObject = SSLContext.RunMethod("getSocketFactory", Null)
Return Factory '<---- Here ERROR
End Sub
When run i have this error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
mjpeg_createtrustallsslsocket (java line: 178)
java.lang.RuntimeException: Field: socket not found in: anywheresoftware.b4a.objects.SocketWrapper
at anywheresoftware.b4j.object.JavaObject$FieldCache.getField(JavaObject.java:306)
at anywheresoftware.b4j.object.JavaObject.SetField(JavaObject.java:173)
at b4a.example.mjpeg._createtrustallsslsocket(mjpeg.java:178)
at b4a.example.mjpeg._connect(mjpeg.java:160)
at b4a.example.main._activity_create(main.java:347)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Any idea ?
Thank you
Marco