Add more frequent auto-updates on unmetered networks
This commit is contained in:
parent
731c35434e
commit
146acd4483
|
@ -36,6 +36,7 @@ public class UpdateScheduler {
|
|||
|
||||
Constraints constraints = new Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.setRequiresBatteryNotLow(true)
|
||||
.build();
|
||||
|
||||
PeriodicWorkRequest updateRequest =
|
||||
|
@ -45,6 +46,21 @@ public class UpdateScheduler {
|
|||
.build();
|
||||
|
||||
getWorkManager().enqueue(updateRequest);
|
||||
|
||||
constraints = new Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.UNMETERED)
|
||||
.setRequiresBatteryNotLow(true)
|
||||
.setRequiresDeviceIdle(true)
|
||||
.build();
|
||||
|
||||
updateRequest =
|
||||
new PeriodicWorkRequest.Builder(UpdateWorker.class, 6, TimeUnit.HOURS)
|
||||
.addTag(AUTO_UPDATE_WORK_TAG)
|
||||
.setInitialDelay(6, TimeUnit.HOURS)
|
||||
.setConstraints(constraints)
|
||||
.build();
|
||||
|
||||
getWorkManager().enqueue(updateRequest);
|
||||
}
|
||||
|
||||
public void cancelAutoUpdateWorker() {
|
||||
|
|
Loading…
Reference in New Issue