use of androidx.work.OneTimeWorkRequest in project OneSignal-Android-SDK by OneSignal.
the class OSNotificationRestoreWorkManager method beginEnqueueingWork.
public static void beginEnqueueingWork(Context context, boolean shouldDelay) {
// When boot or upgrade, add a 15 second delay to alleviate app doing to much work all at once
int restoreDelayInSeconds = shouldDelay ? 15 : 0;
OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(NotificationRestoreWorker.class).setInitialDelay(restoreDelayInSeconds, TimeUnit.SECONDS).build();
WorkManager.getInstance(context).enqueueUniqueWork(NOTIFICATION_RESTORE_WORKER_IDENTIFIER, ExistingWorkPolicy.KEEP, workRequest);
}
use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.
the class SyncService method sync.
public static void sync(Context context) {
OneTimeWorkRequest workRequest = getWorkRequest().build();
WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_SYNC, ExistingWorkPolicy.REPLACE, workRequest);
}
use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.
the class AutoUpdateManager method runOnce.
/**
* Run auto feed refresh once in background, as soon as what OS scheduling allows.
*
* Callers from UI should use {@link #runImmediate(Context)}, as it will guarantee
* the refresh be run immediately.
* @param context Context
*/
public static void runOnce(Context context) {
Log.d(TAG, "Run auto update once, as soon as OS allows.");
OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(FeedUpdateWorker.class).setConstraints(getConstraints()).setInitialDelay(0L, TimeUnit.MILLISECONDS).setInputData(new Data.Builder().putBoolean(FeedUpdateWorker.PARAM_RUN_ONCE, true).build()).build();
WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_FEED_UPDATE_ONCE, ExistingWorkPolicy.REPLACE, workRequest);
}
use of androidx.work.OneTimeWorkRequest in project ExoPlayer by google.
the class WorkManagerScheduler method schedule.
@Override
public boolean schedule(Requirements requirements, String servicePackage, String serviceAction) {
Constraints constraints = buildConstraints(requirements);
Data inputData = buildInputData(requirements, servicePackage, serviceAction);
OneTimeWorkRequest workRequest = buildWorkRequest(constraints, inputData);
workManager.enqueueUniqueWork(workName, ExistingWorkPolicy.REPLACE, workRequest);
return true;
}
use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.
the class SyncService method syncImmediately.
public static void syncImmediately(Context context) {
OneTimeWorkRequest workRequest = getWorkRequest().setInitialDelay(0L, TimeUnit.SECONDS).build();
WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_SYNC, ExistingWorkPolicy.REPLACE, workRequest);
}
Aggregations