public interface BackgroundFetch
Background fetch is a mechanism whereby an application is granted permission by the operating system
to update its data periodically. At times of the native platform's choosing, an app that supports background
fetch will be started up (in the background), and its
performBackgroundFetch(long, com.codename1.util.Callback) method will be called.
Note: Since the app will be launched directly to the background, you cannot assume that the
start() method has been
run prior to the
performBackgroundFetch(long, com.codename1.util.Callback) method being called.
Apps that wish to implement background fetch must implement the
in their main class. On iOS, you also need to include
fetch in the list of background
modes (i.e. include "fetch" in the
ios.background_modes build hint.)
In addition to implementing the
BackgroundFetch interface, apps must explicitly set the background fetch interval
Display.setPreferredBackgroundFetchInterval(int) at some point, usually in the
Currently background fetch is supported on iOS, Android, and in the Simulator (simulated using timers when the app is paused). You should
Display.isBackgroundFetchSupported() method to find out if the current platform supports it.
deadline- The deadline (milliseconds since epoch) by which the fetch should be completed. If not completed by this time, the app may be killed by the OS. On iOS, there is a limit of 30 seconds to perform background fetches.
onComplete- Callback that MUST be called when the fetch is complete. If it is not called, some platforms (e.g. iOS) may refuse to allow the app to perform background fetches in the future.