Android Question How to keep apps running that use StartServiceAt in a loop

JackKirk

Well-Known Member
Licensed User
This is more of an open discussion than a solution.

According to this thread StartServiceAt uses the Android AlarmManager to do its tricks.

While googling Android AlarmManager I came across this hit which I found most interesting:

https://stackoverflow.com/questions/34729966/alarmmanager-not-working-in-several-devices

Basically the discussion revolves around how some phone manufacturers add "power/battery saving" apps that pay no attention to AlarmManager settings and kill apps as they please.

I have looked at the 2 android phones I use to run apps that use StartServiceAt in Service_Start to create a continuously running app and found both of them had "power/battery saver" apps and both were set to destroy my continuously running apps at some point.

I have now reconfigured the "power/battery saver" apps to leave my apps alone.

I will report back in this thread what the ultimate effect is.

One other thing that came out of the interesting hit was the suggestion of Android devices running "vanilla Android" - i.e. with out battery savers.

Does anyone know of such a "vanilla" device?
 

JackKirk

Well-Known Member
Licensed User
I decided to do some testing.

As mentioned above, I have an app that runs on my personal phone (Samsung S5 Android 6.0.1) that receives various alerts and diagnostics on what is going on in my AWS project.

It uses StartServiceAt in Service_Start that runs nominally every 60 seconds.

Contrary to my previous statements this app runs in foreground mode (Service.StartForeground statement in Sevice_Start)

I have added timing info to the notification it issues every loop.

This is very consistently showing 59 or 60 seconds.

If I change the loop timing to a nominal 30 seconds it very consistently shows 29 or 30 seconds.

Is this good result because of the age of my Android?
 
Last edited:
Upvote 0
Top