Android -How to run services in background when certain criteria meets how to display the notification -


how can run services in background of battery manager android application?

how display or receive notification when battery low or when criteria met?

for example, alarm, when current time equals alarm time alarm rings.

you have 3 options:

  1. you create long running service. spawns off thread checks things mentioned periodically. wouldn't advise tho, these services tend killed on long run os. also, you'd have use wake locks prevent system put cpu on idle when phone goes idle after minutes of inactivity - stopping service.

  2. check out available system events can register broadcast receivers. if find suitable ones (i think there's 1 indicating low battery levels), write receivers them.

  3. use timing service register intents fired off on regular intervals. these intents start service (a short running one) thing.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -