-3

I'm developing an android app to check data from a website and notify the user when there is a change. So I want to create a scheduled task that runs in the background and execute a method every 60 seconds.

I searched a lot on the Internet and found:

  1. an Intent, which stops if the app is not running in the foreground.
  2. a JobSchedular where the smallest interval is 15 minutes.

So is there any opportunity to run a task in the background every 60 seconds in android?

Best regards AndroidMaster

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • `every 60 seconds` is not possible without a visible process(Foreground Service). Apart from that you can use FCM to notify the device that data is changed And next time app open it will sync the latest data or you can shedule a task for syncing. – ADM Jul 08 '18 at 15:32
  • And how do it WhatsApp or Skype? – AndroidMaster Jul 09 '18 at 05:37

1 Answers1

-1

You would need to look into AlarmManager class. For example, you could use an alarm to initiate a long-running operation, such as starting a service once a day to download a weather forecast.

It's more efficient that way. Check documentation.

Sreekant Shenoy
  • 1,420
  • 14
  • 23
  • 1
    `AlarmManager` has restrictions starting from Android M . You should check the Documentations. – ADM Jul 09 '18 at 05:47