Android Question wait for 60 sec then stop audio recording

Devv

Active Member
Licensed User
Longtime User
What is the best way to sleep after audio recording started ?
i'am making a simple app that record audio for 60 seconds
i was able to do the recording and stop it with button
but i want to make it as an service not a GUI app
after i start the recording what is the best way to wait for 60 seconds then stop the recording ?
 

stevel05

Expert
Licensed User
Longtime User
Use a Timer set it for 60000 (Milliseconds) and stop the recording in the Timer_Tick sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Something like this:

B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim Timer1 As Timer
End Sub
Sub Service_Create
    Timer1.Initialize("Timer1",60000)
End Sub

Sub Service_Start (StartingIntent As Intent)
    'Or wherever you start Recording
    Timer1.Enabled = True

End Sub

Sub Service_Destroy

End Sub
Sub Timer1_Tick
    Timer1.Enabled = False
    'Call your stop recording method
End Sub

Put the Timer1.Enabled = True call right after your startrecording command
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User

perfect thank you...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…