Hi, I create a service that will turn screen on when an event raise. After 5 seconds, I want to turn screen off and service need to keep running. Because I don't know how to turn screen on/off automatically so I use PhoneWakeState to do it. I thought PhoneWakeState.PartialLock can keep service running but it not. Any suggestion for me? Thank you.
B4X:
Dim ph As PhoneWakeState
Dim t as Timer
t.Initialize("t", 5000)
Sub Service_Start (StartingIntent As Intent)
' Some code
ph.PartialLock
Service.StartForeground(1, noti)
' Some code
End Sub
' Some code to handle event
Sub TurnScreenOn
ph.ReleaseKeepAlive
ph.KeepAlive(True) ' Turn screen on
t.Enabled = True
End Sub
Sub t_tick
TurnScreenOff ' Turn screen off after 5 seconds
End Sub
Sub TurnScreenOff
ph.ReleaseKeepAlive ' Turn screen off
ph.PartialLock ' Try to keep service running but... failed!
End Sub