What is the way to prevent a Service from firing when the phone is in Sleep state (the screen turns off)?
My B4A wallpaper changer works great. I changed the update time in the Activity module to 20 seconds to see what else was happening and when I manually woke the screen, the screen updated multiple times in 5 seconds:
Then I read that "Even if the service is stopped, StartServiceAt will start it again. This is the whole purpose of StartServiceAt."
I have done both in myOwnService service:
My B4A wallpaper changer works great. I changed the update time in the Activity module to 20 seconds to see what else was happening and when I manually woke the screen, the screen updated multiple times in 5 seconds:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
StartServiceAt(upDateWalpapr, DateTime.Now + 20000, True) ' 20 seconds for testing
End Sub
I have done both in myOwnService service:
B4X:
#Region Service Attributes
#StartAtBoot: True
' #StartCommandReturnValue: android.app.Service.START_STICKY
B4X:
Sub Service_Start (StartingIntent As Intent)
Log(" my Service_Started upDateWalpapr")
StartActivity(theUpdater) ' neither Resume the Activity alone, both seem needed
CallSubDelayed(theUpdater, "changePicture") ' neither Resume the Activity alone, both seem needed
' Starter.csu.CallSubPlus(theUpdater, "changePicture", 6000) 'DOES IT STOP SCREEN UPDATE ? ? ' doesn't help
End Sub
B4X:
Sub changePicture
If Starter.gtum = Starter.lstGlbl.Size - 1 Then
Starter.gtum = 0
Log(" lstGlbl.Size maxed")
Else
Starter.gtum = Starter.gtum + 1
Log(" lstGlbl.Size NOT maxed")
End If
SetWallPaper(LoadBitmap(Starter.daPaf, Starter.lstGlbl.Get(Starter.gtum))) ' change wallpaper
End Sub