Questions tagged [android-workmanager]

Android Jetpack WorkManager is used for scheduling and managing one time and periodic background tasks.

Android Jetpack WorkManager makes it easy to schedule deferrable background work.

The library schedules your job at a battery-friendly time ensuring your task runs even after your app exits.

Android Jetpack WorkManager makes it easy to schedule deferrable background work.

The library schedules your job at a battery-friendly time ensuring your task runs even after your app exits.

Key features:

  • Backwards compatible up to API 14
  • Add work constraints like network availability or charging status
  • Schedule asynchronous one-off or periodic tasks
  • Monitor and manage scheduled tasks
  • Chain tasks together

WorkManager’s Resources

Official materials:

Official articles and tutorials:

1321 questions
93
votes
9 answers

More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

i am trying android WorkManager, The code is throwing error "More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro" when running, I tried the following answer, it was not helpful. WorkManager…
Basha K
  • 1,509
  • 1
  • 11
  • 16
88
votes
7 answers

Android WorkManager vs JobScheduler

Why do we need the new Android WorkManager if we already have a JobScheduler along with a few nifty backports (AndroidJob and FirebaseJobDispatcher) with the same functionality? Does it have any killer-features or something? Because I don't see…
Nikolay Kulachenko
  • 4,604
  • 4
  • 31
  • 37
81
votes
3 answers

Android. Is WorkManager running when app is closed?

I want to schedule nightly database updates. So I use new Android WorkManager. My understanding is that once scheduled it will always run in the background independently from the app's lifecycle. Is that right? My first tests show that Work is only…
80
votes
8 answers

Schedule a work on a specific time with WorkManager

WorkManager is a library used to enqueue work that is guaranteed to execute after its constraints are met. Hence, After going though the Constraints class I haven't found any function to add time constraint on the work. For like example, I want to…
S Haque
  • 6,881
  • 5
  • 29
  • 35
64
votes
1 answer

Android Work Manager vs Services?

In my Android app i have multiple intent services which run one after another and the very first intent service is trigerred by a broadcast. I came across Work Manager a few days ago and really liked the simplicity of the Worker and the WorkManager…
Dishonered
  • 8,449
  • 9
  • 37
  • 50
63
votes
2 answers

How to create a Worker with parameters for in WorkManager for Android?

Android architecture has a new components WorkManager. From the example, class CompressWorker(context : Context, params : WorkerParameters) : Worker(context, params) { override fun doWork(): Result { // Do the work here--in this…
63
votes
4 answers

How to solve 'Program type already present: com.google.common.util.concurrent.ListenableFuture'?

I am trying to use WorkManager 1.0.0-alpha09. and getting this error: Program type already present: com.google.common.util.concurrent.ListenableFuture Message{kind=ERROR, text=Program type already present:…
Simran Marok
  • 707
  • 1
  • 5
  • 9
57
votes
8 answers

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent, On AlarmPingSender

Problem Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. I got it after updating target SDK to 31. the error always come after AlarmPingSender. But i dont know any…
56
votes
7 answers

Check if WorkManager is scheduled already

How can I check if WorkManager is scheduled already. Here is my code that schedule WorkManager. public static void scheduleWork() { PeriodicWorkRequest.Builder photoCheckBuilder = new…
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
56
votes
9 answers

Asynchronous Worker in Android WorkManager

Google recently announced new WorkManager architecture component. It makes it easy to schedule synchronous work by implementing doWork() in Worker class, but what if I want to do some asynchronous work in the background? For example, I want to make…
46
votes
1 answer

WorkManager vs AlarmManager, what to use depending on the case

I have to perform this use case (not code , just the right usage) The use case : I need to fetch some data from the network everyday at 00:30 . These data provide me some specific times , and one of them is around 4:30 (changes everyday by +1 minute…
coroutineDispatcher
  • 7,718
  • 6
  • 30
  • 58
39
votes
2 answers

How does setExpedited work and is it as good&reliable as a foreground service?

Background In the past, I used a foreground IntentService to handle various events that come one after another. Then it was deprecated when Android 11 came (Android R, API 30) and it was said to prefer to use Worker that uses setForegroundAsync…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
37
votes
13 answers

Android Work Manager: "Could not instantiate Worker"

I've followed the Android Developer's tutorial on using the Worker Manager structure to run my code in background but anytime I try to enqueue my worker it doesn't run and I get the following error: 2018-10-04 22:25:47.004…
Ícaro
  • 1,432
  • 3
  • 18
  • 36
37
votes
4 answers

Execute task every second using Work Manager API

Work Manager is a new API and I try to execute task every second, but it doesn't work. This is my worker class class TestingWorker : Worker(){ override fun doWork(): Result { Log.i("CheckWorker","Result here") return…
31
votes
6 answers

IllegalStateException: WorkManager is already initialized

Having these dependencies: dependencies { implementation "androidx.work:work-runtime:2.0.1" androidTestImplementation "androidx.work:work-testing:2.0.1" } When running this code for the second time: Configuration config = new…
1
2 3
87 88