Play sound with phone off

DB100

New Member
Licensed User
Longtime User
I have a count-down timer app that uses a Service module. It generates a sound when it reaches zero. If I start it at 1 min and then turn-off the phone, the sound won't play. After the timer is over, when I turn the phone back on, the sound plays. It's as if the sound is in some sort of queue, and can't play til the phone is turned on. I have experimented with different methods for generating the sound:

MediaPlayer
Notification.sound
Beep

They all work the same. They won't play when the phone is off, but do play when the phone is turned back on. I have downloaded count-down timers from Google Play and they do play a sound when the phone is off. So it's not the phone and it's not Android. It must be B4A. Is there a way in B4A to play a sound when the phone is off? Thanks.
 

DB100

New Member
Licensed User
Longtime User
You have to keep your service "alive", read THIS or search the forums for Services Tutorial
I tried this. It's a sub within the service.
It didn't work. It acted the same as I described above:

Sub PlaySound
'Use Notification to play sound.
'DateTime.TimeFormat = "hh:mm:ss"
'File.WriteString(gsFilePath,"MyTimerX.txt",DateTime.Time(DateTime.Now))
goNotify.Icon = ""
goNotify.Light = False
goNotify.Vibrate = False
goNotify.Sound = True
Service.StartForeground(2,goNotify)
'goNotify.Notify(2)
End Sub
 
Upvote 0
Top