service - Best practice for scehduled background task Android -


i creating notification app, alert user after set reminder notification. current implementation logic is:

  1. create service, starts running in background when user opens app.
  2. in oncreate() method of service, implementing timer task repeat after 5000ms interval , call method, check reminders set user , notify user if reminder set current time.
  3. i use broadcast receiver run service on boot_completed event, if in case user turns off phone.

this implementation working good, have faced no issues it, concern is practice? keeping in mind service running , checking every 5 secs consume battery. if user turns on stamina mode, power saving mode or such mode, os kill service. there can give priority service not killed.

if there other more efficient way implement sort of task, want implement in project.

looking forward suggestions.

much appreciated.

best approach wakeful intent service alarm receiver mentioned here

https://github.com/commonsguy/cwac-wakeful


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -