java - How to Realize an Update Service is Running in the Background? -


i'm working on app android os displays data. ensure data up-to-date, required app fetches updates remote server time time. data not change often, update should carried out once per week. want give user ability choose weekday , daytime of update (and optionally disable feature completely).

the thing is: update should carried out when user not using phone @ moment, when phone sleeping , when phone has been rebooted , app hasn't been started yet.

the first thing thought of remote service starts @ system boot, determines time when run update, sets timer , waits/sleeps timer fire.

now, told should rather use alarm timers or kind of handlers... more read topic, more ways seem exist.

now, i'm bit lost method best me... here need:

  • i want execute code @ time specified.
  • this timer used trigger execution of code 7 days in future. (i.e., every week @ given weekday , time)
  • the code should run without waking phone if "sleeping" (screen dimmed).
  • when running code, no activity should started. i.e. no app pops on screen.
  • the code executed should fetch data internet. if @ time no internet connection available, timer should set sleep 30 minutes , try again.
  • after completing code execution, timer set next interval, 7 days later.
  • the timer should started @ system boot, e.g., if reboot phone, timer should determine next date execute code , schedule timer. has work without user interaction! (i.e. without app being started itself)
  • when "sleeping", thread/service/timer/whatsoever should not consume system resources if possible...
  • need pretty simple unix cronjob.

    i think here knows "newsrob" android? want realize pretty same newsrob-updateservice.

  • android service + broadcast receiver + alarm service solve purpose -

    your service invoked broadcast receiver , in broadcast receiver should register various events - boot_receiver , action_user_present , take care of alarm reset , update task.

    thanks.


    Comments

    Popular posts from this blog

    ASP.NET/SQL find the element ID and update database -

    jquery - appear modal windows bottom -

    c++ - Compiling static TagLib 1.6.3 libraries for Windows -