Thanks Erel for your links. I'm trying to keep the service working.
I currently have this code:
Sub Service_Create
Syntezator.Initialize("TTS")
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
PWS.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(1,n2)
StartServiceAt(Me, DateTime.Now + 20*1000,True)
checkConnect
End Sub
the effect is that as the phone's screen is active, the service is called every 20 seconds.
But when the screen is turned off, after some time the service does not work anymore. Only when the phone is unlocked will it start again.
I need the service to work all the time and show me notifications when I receive a message from MQTT.
How can I do this?