Android Question SOLVED Error class jobdone

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hi!

create a class to test connectivity.
but it generates an unexpected error. java.lang.RuntimeException: java.lang.NoSuchFieldException: processBA

I share a test project that replicates the error.
can you help me solve it?
The error occurs when executing the job in the clsControlconnectivity class, line 32

** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
java.lang.RuntimeException: java.lang.NoSuchFieldException: processBA
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1181)
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1192)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
Caused by: java.lang.NoSuchFieldException: processBA
at java.lang.Class.getField(Class.java:1604)
at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:1219)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1126)
... 8 more
[CODE lang="b4x" title="B4XMainPage" highlight="in manifest add CreateResourceFromFile(Macro, Core.NetworkClearText)"]#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private conectividad As clsControlConectividad
End Sub

Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
conectividad.Initialize("a","b","B4XMainPage")
conectividad.gsub_control_conectividad

End Sub


Sub a

xui.MsgboxAsync("A!", "B4X")
End Sub

Sub b

xui.MsgboxAsync("B!", "B4X")
[/CODE]
Regards
 

Attachments

Last edited:
this is wrong:
B4X:
           lo_job.Initialize(msObjeto & "_control_conexion", msObjeto) ', msObjeto)

the 2nd parameter of httpjob.initialize() is an object, not a string
you define it as a string.

if you change your call to
B4X:
lo_job.Initialize(msObjeto & "_control_conexion", Me) ', msObjeto)
it will work.

using a string prevented the proper resolution of processBA and threw the exception
 
Upvote 0
I found the problem, In addition to what is indicated by @drgottjr
class does not accept callsubdelayed.
replace it with returns a variable
and converted the function to resumabled

in b4xmaginpage

[CODE lang="b4x" title="B4XMainPage"]Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private conectividad As clsControlConectividad
Private resultado_conectividad As String
End Sub

Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
conectividad.Initialize("a","b","B4XMainPage")
wait for(conectividad.gsub_control_conectividad) complete (resultado As String)

CallSubDelayed(Me,resultado)

End Sub


Sub a

xui.MsgboxAsync("A!", "B4X")
End Sub

Sub b

xui.MsgboxAsync("B!", "B4X")
End Sub[/CODE]

in class module

[CODE lang="b4x" title="class module"]Sub Class_Globals
Public mb_conectado As Boolean = False
Public mdt_fecha_control_conectado As Long = 0
Dim msObjeto As String = "clsControlConectividad"

Private ls_funcion,ls_funcion_err,ls_modulo As String
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (ms_funcion As String, ms_funcion_err As String, ms_modulo As String)

ls_funcion = ms_funcion
ls_funcion_err = ms_funcion_err
ls_modulo = ms_modulo

End Sub


Sub gsub_control_conectividad As ResumableSub

Dim lo_job As HttpJob

mb_conectado = True

If mdt_fecha_control_conectado < DateTime.Now Then
mb_conectado = False
Try
lo_job.Initialize("lo_job", Me)
lo_job.GetRequest.Timeout = 50000000
lo_job.Download("http://www.google.com")
Wait For (lo_job) JobDone(lo_job As HttpJob)

If lo_job.Success Then
mb_conectado = True
End If
lo_job.Release

Catch
Log(DateTime.Time(DateTime.Now) & " : " & LastException)
End Try

If lo_job <> Null Then
If lo_job.IsInitialized Then
lo_job.Release
End If
End If

Dim lo_per As Period
lo_per.Initialize
If mb_conectado = False Then
lo_per.Seconds = 5
Else
lo_per.Seconds = 20
End If
mdt_fecha_control_conectado = DateUtils.AddPeriod(DateTime.Now, lo_per)



If mb_conectado Then

If ls_funcion <> "" Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Return ls_funcion
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

End If
Else
If ls_funcion_err <> "" Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Return ls_funcion_err

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
End If

End If


End Sub



[/CODE]
 
Last edited:
Upvote 0
Back
Top