Android Question How do I pass the activity to a function?

davepamn

Active Member
Licensed User
Longtime User
B4X:
'Class_Globals
Sub Class_Globals
public oClassActivity as activity
end sub

'Activity Code
oClass.TransmitToServer(Activity)

'Class Code
Sub TransmitToServer(oActivity As Activity) As String
oClassActivity=oActivity
end sub
sub JobDone(Job as HttpJob)
  callsubdelayed2(oClassActivity,"TransmitToServer_Finished","")
end sub

I need the activity so I can CallSubDelayed2(oClassactivity,"my function","") from the class once a job is done.
 
Last edited:

davepamn

Active Member
Licensed User
Longtime User
Changed too:
B4X:
Class_Globals
  private oClassActivity as object
end Class
oClass.TransmitToServer(me)

sub TransmitToServer(oActivity as object)
  oClassActivity=oActivity
end sub

sub jobdone(job as httpjob)

if job.success then
    callSubDelayed2(oClassActivity,"TransmitToServer_Finished","")
end if

This worked

I have to encapsulate my code, so I can share it when unit testing
 
Last edited:
Upvote 0

ArminKH

Well-Known Member
B4X:
'Class Code
Sub TransmitToServer(vCallBack As Object) As String
    oClassActivity = vCallBack
End Sub
Sub JobDone(Job As HttpJob)
  CallSubDelayed2(oClassActivity,"TransmitToServer_Finished","")
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top