Android Question Sticky Service Not ReStarting

Jonathan Rigley

Member
Licensed User
I've got an app on the market but a customer as pointed out a bug.

Basically install the app and restart the phone. Open the app choose new vehicle enter the mot tax and insurance dates and enter the alarm time. Switch off the screen and. The alarm fires up as it should. If I add a new vehicle dates and alarm time it won't fire again with the screen off unless the phone is rebooted.

Hope this is enough info and makes sense.


https://play.google.com/store/apps/details?id=com.simple_vehicle_reminder&hl=en

Jonathan Rigley
 

Attachments

Mark Ryan Penafiel

Member
Licensed User
Sorry DonManfred if it is not clear with me,
does it mean I will call to start the service every interval using StartServiceAt ?

in other words( the service will call itself to start itself (for example every 1 min?)


I am have an app that should not be killed. it works fine on earlier version but when installed at android 4.4, sometime it stop. i am using sticky service and StartServiceAt

Thanks
 

Jonathan Rigley

Member
Licensed User
Use:

B4X:
StartServiceAt(YourServiceName, DateTime.Now, True)
This will start your service straight away. The service will get killed but will automataclly start again.

Don't forget to add:

B4X:
#Region  Service Attributes
    #StartAtBoot: True
    #StartCommandReturnValue: android.app.Service.START_STICKY   
#End Region
At the top of your Service module.

Jonathan
 

DonManfred

Expert
Licensed User
does it mean I will call to start the service every interval using StartServiceAt ?
No. startserviceat is a ONE-TIME-Shedule... If you set the time to 1 minute in future then the service will be killed and restarted at the given time.
It is up to the service to reshedule itself again with startserviceat AFTER the service has done it´s work...

1- svc gets started
2- svc do his work.
3- svc do a reshedule for itself with a new time. After calling the startserviceat the service get´s killed.
4- At the sheduled time (more or less exact) it goes back to "1- svc gets started"...
 

DonManfred

Expert
Licensed User
This will start your service straight away. The service will get killed but will automataclly start again.
I dont think that this is the suggested way. it may be hard for the battery as the service is starting again and again and again and again........
 

Mark Ryan Penafiel

Member
Licensed User
Thanks for the opinons

im using this

StartServiceAt("", DateTime.Now + 1 * DateTime.TicksPerMinute, True)


so the service will do a scheduled task every minute (sending gps location)


and
#StartCommandReturnValue: android.app.Service.START_STICKY

#StartAtBoot: True



but less than 24 hrs, the service is not transmiting any data any more, it seems that it just stoped

what is the suggested way for this


thanks in advance
 
Top