service - Best practice for scehduled background task Android -
i creating notification app, alert user after set reminder notification. current implementation logic is:
- create service, starts running in background when user opens app.
- 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.
- 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
Comments
Post a Comment