use of androidx.work.WorkRequest in project Tusky by Vavassor.
the class NotificationHelper method enablePullNotifications.
public static void enablePullNotifications(Context context) {
WorkManager workManager = WorkManager.getInstance(context);
workManager.cancelAllWorkByTag(NOTIFICATION_PULL_TAG);
WorkRequest workRequest = new PeriodicWorkRequest.Builder(NotificationWorker.class, PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS, TimeUnit.MILLISECONDS, PeriodicWorkRequest.MIN_PERIODIC_FLEX_MILLIS, TimeUnit.MILLISECONDS).addTag(NOTIFICATION_PULL_TAG).setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()).build();
workManager.enqueue(workRequest);
Log.d(TAG, "enabled notification checks with " + PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS + "ms interval");
}
use of androidx.work.WorkRequest in project fdroidclient by f-droid.
the class WifiStateChangeService method start.
public static void start(Context context, @Nullable Intent intent) {
int networkInfoStateInt = NETWORK_INFO_STATE_NOT_SET;
if (intent != null) {
NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
networkInfoStateInt = ni.getState().ordinal();
}
WorkRequest workRequest = new OneTimeWorkRequest.Builder(WifiStateChangeService.class).setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()).setInputData(new Data.Builder().putInt(WifiManager.EXTRA_NETWORK_INFO, networkInfoStateInt).build()).build();
WorkManager.getInstance(context).enqueue(workRequest);
}
Aggregations