Android Question Jobscheduler

LucaMs

Expert
Licensed User
Longtime User
I have "with difficulty" developed a little project that could be a basis for an app-service that remains always active (a bit like the project always cited as an example, "Background location tracking").

Now I would like to use it to develop an app that performs certain tasks N times a day, M days a week, just like the "Alarm Clock" app that I have in my smartphone (pre-installed).

I searched JobScheduler site but I found this answer by Erel:

What are you trying to accomplish? You can probably use StartServiceAt to do it.

Do you think that StartServiceAt (or StartServiceAtExact) can be used for this task or that JobScheduler is necessary?
There is very little about the latter on site.
 

LucaMs

Expert
Licensed User
Longtime User
I just asked ChatGPT; the beginning of its answer is encouraging, but I still have to look at the tons of errors that it will have made

The question was about the two alternatives, JobScheduler and StartServiceAt/StartServiceAtExact.

(ChatGPT)
You can handle everything using the existing service (srvForeground) in combination with StartServiceAtExact. This method offers more control and precision than the JobScheduler, especially in Android versions prior to 8.0 (Oreo), where the JobScheduler has more stringent limitations in terms of minimum periodicity and power consumption.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
jobscheduler is less time-related than startserviceat.
it can actually have nothing to do with a given time of day,
whereas startserviceat is nothing without a time of day.

with jobscheduler, the os decides when to run your jobs.
with startserviceat, the app decides (but MAY be delayed
by the os).

jobscheduler survives rebooting, startserviceat doesn't.
(of course, you can cause your app to run after reboot, so
that issue is moot.)

jobscheduler makes sure your job - once running - isn't killed.
unclear what kinds of guarantees you have with startserviceat.

with jobscheduler, battery issues are handled by the os. with
startserviceat, you usually have to deal with these yourself (by learning
all the various conditions under which your app can function).

in addition to jobscheduler and startserviceat, there is also the
alarm broadcast receiver, and SetExactAndAllowWhileIdle you
can look into.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User

Anyway, I don't think there's a good B4A JobScheduler library, so I'll try with StartServiceAtExact.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…