08-07 11:23:15.905 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:23:15.917 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:23:46.052 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:23:46.062 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:24:46.323 11773-11872/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:24:46.328 11773-11872/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:26:46.560 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:26:46.566 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:30:46.794 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:30:46.799 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:39:42.133 11773-11872/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:39:42.139 11773-11872/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:55:42.240 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:55:42.255 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 12:27:42.400 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 12:27:42.413 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
iamkdblue, BenoitDuffez, gurleensethi, rushdroid, pess0a, 02gaurav, rodgarcialima, Shamyyoun, siaLp2020, sac-sha, and 10 more reacted with thumbs up emoji
vferreirati, rushdroid, cassioso, ThisIsAreku, SaeedMasoumi, gsandaru, tsal, rezazarchi, OhhhThisVarun, and tongbaoloc reacted with confused emoji
sac-sha and kanghb reacted with rocket emoji
All reactions
15 minutes is min, you can see in the source:
public final class PeriodicWorkRequest extends WorkRequest { /** * The minimum interval duration for {@link PeriodicWorkRequest} (in milliseconds). */ public static final long MIN_PERIODIC_INTERVAL_MILLIS = 15 * 60 * 1000L; // 15 minutes. /** * The minimum flex duration for {@link PeriodicWorkRequest} (in milliseconds). */ public static final long MIN_PERIODIC_FLEX_MILLIS = 5 * 60 * 1000L; // 5 minutes.
It would be nice to have this specified in the documentation though (or maybe fail fast and throw a RuntimeException if you try to go under this?)
I created 20 min interval periodic work request but it's not working periodically. It runs just once when app runs first time. am I doing something wrong?
My Worker class
public class MyCustomWorker extends Worker {
@NonNull
@Override
public Result doWork() {
Log.d("Worker", "doWork() called");
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_DEFAULT);
// Configure the notification channel.
notificationChannel.setDescription("Channel description");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), NOTIFICATION_CHANNEL_ID);
notificationBuilder.setAutoCancel(false)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.mipmap.ic_launcher)
.setTicker("Hearty365")
.setPriority(Notification.PRIORITY_MAX)
.setContentTitle("Default notification")
.setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
.setContentInfo("Info");
notificationManager.notify(/*notification id*/1, notificationBuilder.build());
return Result.SUCCESS;
Initialization of periodic work
private void prepareWork(){
PeriodicWorkRequest.Builder myWorkBuilder =
new PeriodicWorkRequest.Builder(MyCustomWorker.class, 20, TimeUnit.MINUTES);
PeriodicWorkRequest myWork = myWorkBuilder.build();
WorkManager.getInstance()
.enqueueUniquePeriodicWork("jobTag", ExistingPeriodicWorkPolicy.KEEP, myWork);
Device -> Nexus 5X Api 27 Emulator
WorkManager version -> 1.0.0-alpha07
Thanks for reporting this.
I'm closing this issue because this forum is for issues with the codelab.
If you think that this is a problem of the WorkManager library, please open a bug on the WorkManager public issue tracker: https://issuetracker.google.com/issues/new?component=409906&template=1094197
Please reopen if you still think this is an issue with the codelab.
The same issue, PeriodicWorkRequests only run a single time, when I remove the app from the background.
library : implementation 'androidx.work:work-runtime:2.2.0'
Component: PeriodicWorkRequests, WorkManager
Mobile: Vivo 1804
Android version: 9 pie
PeriodicWorkRequests only run a single time, when I remove the app from the background.
library version ::1.0.0-alpha11
device honor 9n