Android Question How to create an event?

Xandoca

Active Member
Licensed User
Longtime User
Hi,

What are the steps to create an event?
My objective is: A class or object that wait n seconds and when it complete (wait n seconds) it raises the event complete, like mediaplayer complete.

I want that because my app show wait some time before running the next music file. It works fine but if I try to back or forward the music that app don't respond because I've implement the wait sub like:

B4X:
Sub WaitSeconds(seconds As Int)
Dim Ti As Long
  Ti = DateTime.Now + (seconds * 1000)
  Do While DateTime.Now < Ti
      DoEvents
  Loop
End Sub
Thanks
 

Xandoca

Active Member
Licensed User
Longtime User
Use a Timer, the Timer _Tick callback is your completed event.
Thanks!
I have to implement it on a service. I've try but it seems to work only with activities.
Is there another option or I'm doing something wrong?

Best Regards.
 
Upvote 0

Xandoca

Active Member
Licensed User
Longtime User
Thank you guys. The problem was I've put the timer on a code module and then call it from a service. It doesn't work.
I put the timer in the service and it works.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…