1

I have an android application (minSdkVersion=7), which should send/receive some data to the server once per day. What is the best way to organize such synchronization?

In my previous application I used background Service which checks every X mins if 1 day is passed. But I don't like this approach since the service is always running. Is there any other way to achieve the same?

What is synchronization should happen not once per day, but once per hour? Does it change the approach?

One more item to be considered - I perform synchronization only if wi-fi connection is available. If it is not, I shouldn't wait for 1 more day. The app should try to perform another synchronization let's say in 15 minutes.

LA_
  • 19,823
  • 58
  • 172
  • 308
  • 1
    possible duplicate of [Running task periodicaly(once a day/once a week)](http://stackoverflow.com/questions/8615543/running-task-periodicalyonce-a-day-once-a-week) – Michael Hampton Nov 25 '13 at 19:08

1 Answers1

1

If you know in advance the time to do something, ie once a day, in four hours or so, you can use Android AlarmManager and a BroadcastReceiver. In that way you do not need to have a Service that spends most of its time waiting.

An example can be found here.

Community
  • 1
  • 1
hakanostrom
  • 1,081
  • 8
  • 15