java - how to schedule some code execution in android or: what exactly are daemon threads in android? -


i'm working on app android os requires fetch data remote server time time.

as "update" should carried out when actual frontend app not running, implemented remote service started on system boot. need schedule timer start update.

is "timer"-class right 1 job? , if "yes": difference between "normal" timer() , 1 started "daemon" timer(true)?

http://developer.android.com/reference/java/util/timer.html isn't helpful :(

edit:

ok - see there more methods expected. clarify:

  • 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 sth 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!
  • when "sleeping", thread/service/timer/whatsoever should not consume system resources if possible...

  • what need pretty simple unix cronjob.

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

use alarmmanager. allows set schedule, exit components. code not need remain in memory , triggered when alarm sounds.

i implemented remote service started on system boot

please don't that scheduled task. use alarmmanager.

if want work done while phone asleep, need use _wakeup alarm type , perhaps use wakefulintentservice keep device awake while work being done.


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 -