Display.getInstance().startBackgroundFetchService(new BackgroundFetchTask() {
/**
* Just a null perform fetch that never loads any data.
* This method must return one of RESULT_NEW_DATA, RESULT_NO_DATA,
* or RESULT_FAIL.
*/
@Override
public int performFetch() {
System.out.println("In performFetch()");
return BackgroundFetchTask.RESULT_NO_DATA;
// Note, you could also perform a network request here, but
// it must be performed synchronously as the method
// must return an accurate value when the network
// request is done.
}
/**
* Returns the preferred interval in seconds in which the update should
* run. When running in the foreground the actual interval will be pretty
* close to this preferred interval. When in the background, there are
* no guarantees. E.g. on iOS the OS will only fetch new data between 20
* and 40 times per day per user.
*
* Return 0 to automatically set to the OS minimum value (when in
* foreground, 0 will be rounded up to 1 hour).
*/
@Override
public int getPreferredInterval() {
return 5000;
}
});