Using ReleaseKeepAlive and ReleasePartialLock kills service.

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Using ReleaseKeepAlive and ReleasePartialLock kills the running service. Any way around this?

B4X:
Sub PlayTheChimes
   ntfTheNotification.Notify(2) 

   pwsPhone.KeepAlive(False)
   pwsPhone.PartialLock

   mpMediaPlayer.SetVolume(Main.fltVolume, Main.fltVolume)
   mpMediaPlayer.Play
End Sub

Sub MediaPlayer_Complete
   pwsPhone.ReleaseKeepAlive
   pwsPhone.ReleasePartialLock
End Sub

The service gets turned off after using the "Release". If I comment out those lines the phone screen is dimmed because the cpu is alive and the service stays alive. The downside is that the screen never goes into sleep mode.

If I press the power button to put the phone into sleep mode, nothing happens in the service.

I hope I can get my cake and eat it as well with a work-around. :confused:
 
Last edited:

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Trying this code. I will let you know if it works after some time:

Thanks.

B4X:
Sub Service_Create

   ntfTheNotification.Initialize
   ntfTheNotification.Icon = "icon"    
   ntfTheNotification.Sound = False
   ntfTheNotification.SetInfo("Chimes", "Chimes are now active.", Main)
   ntfTheNotification.Notify(1)
   
   Service.StartForeground(1, ntfTheNotification)
End Sub
 
Last edited:
Upvote 0
Top