Timer with parameters

melamoud

Active Member
Licensed User
Longtime User
hi,

is there a timer like class that can get a parameter ?
any lib that has that ? (I know I can build it myself using some external MAP or something like that)

I want to do something like this.
B4X:
Sub PE_PhoneStateChanged(State As String, IncomingNumber As String, Intent As Intent)    
   t1.Initialize("checkLog",1000*5,IncomingNumber)
End Sub

Sub checkLog_Tick (num As String)
   ' do something with the phone number
End Sub


thanks
 

mc73

Well-Known Member
Licensed User
Longtime User
I think you can simply declare a variable in globals section and use it inside the timer. At least this is what I do in similar cases.
 
Upvote 0

MLDev

Active Member
Licensed User
Longtime User
You can do something like this:

B4X:
Sub Globals
   Dim num As String
End Sub

Sub PE_PhoneStateChanged(State As String, IncomingNumber As String, Intent As Intent)
   num = IncomingNumber
   t1.Initialize("checkLog",1000*5)
End Sub

Sub checkLog_Tick
   ' do something with the phone number in the global variable num
End Sub
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
You can do something like this:

B4X:
Sub Globals
   Dim num As String
End Sub

Sub PE_PhoneStateChanged(State As String, IncomingNumber As String, Intent As Intent)
   num = IncomingNumber
   t1.Initialize("checkLog",1000*5)
End Sub

Sub checkLog_Tick
   ' do something with the phone number in the global variable num
End Sub

the problem with that solution is that if I get two events within 5 second (even if two diffeerent events) the second one will override the first one, in my case I want to fire two events both with different parameters (two numbers)

I can do this using map or some multi objects container, but I was wondering how come no one build such a thing before

nir
 
Upvote 0
Top