Android Question Detect referer activity and call method

devmobile

Active Member
Licensed User
Hey
Please see below code
B4X:
'
1: Sub Class_Globals
2:  
3: End Sub
4:
5: Public Sub Initialize
6:
7: End Sub
8:
9: Sub JobDone(Job As HttpJob)
10:
11:   if job.success then
12:      log("success")
13:   else
14:      'get current activity that use this class
15:      'call method with name "ShowError"
16:   end if
17:
18: End Sub
In line 14 and 15 i need detect current activity and call method in relate activity
I dont want to use CallSub or CallSubDelay
Only need call method with current activity
Thanks
 

devmobile

Active Member
Licensed User
B4X:
Sub Class_Globals
Private mCallback As Object
End Sub

Public Sub Initialize(Callback As Object)
mCallback = Callback
End Sub

Sub JobDone
'...
CallSubDelayed(mCallback, "JobDone_Error")
End Sub

Activity code:
B4X:
MyClassIntance.Initialize(Me)
I knew it but i need to call method with last opened activity
maybe?:(
 
Upvote 0

devmobile

Active Member
Licensed User
Sounds strange. Create a single instance in the starter service.
Set the current activity with this code:
B4X:
Sub Activity_Resume
Starter.YourClassInstance.mCallback = Me
End Sub
Put this code in each of the activities.
Best solution
Thanks
 
Upvote 0
Top