Questions tagged [android-workmanager]

1

votes
2

answer
379

Views

What are differences between BackoffPolicy.EXPONENTIAL and BackoffPolicy.LINEAR when working with Work Manager?

There is no any official doc (as I have read the docs at least) that explain the usage and the mechanism behind these two modes . How do they work ? And what problem do they solve ? I will appreciate that if anyone can simplified it for me , because I have tested both and have not seen any interesti...
Mehdi Jahed Manesh
1

votes
1

answer
253

Views

Inject Object using dagger 2 like DbManager in Worker, to do db operation inside doWork() method, #WorkerManager

Hi I am trying out new WorkerManager in my project and I am not able to figure out how to inject my DbManager class inside my TaskWorker to make use of dbmanager inside doWork() method of workermanager. Also not able to figure out due to TaskWorker Object creation in some what hidden. code example m...
1

votes
2

answer
241

Views

Android - How to check if Worker meet Constraints when is enqueued?

How can I check if the Worker meets Constraints when is enqueued? For example, if I need to download data from the internet and establish that the Worker only runs if there is an internet connection. How can I check at that moment if the Worker meet the Constraints to alert the user? Or if I'm going...
Oscar Méndez
1

votes
1

answer
86

Views

Multiple OneTimeWorkRequests with delay as chain

I'm making an app Medicine Reminder that should remind about medicine consuming based on dates and hours saved in database. Reminding should occur in form of notification. Let's assume that I have one medicine that should be consumed twice (for quick testing for example at 9:50 pm and 9:55 pm). Noti...
patrickz
1

votes
0

answer
651

Views

WorkManager is cancelled after phone goes into doze mode on Samsung Galaxy phones

I am trying to run background service with WorkManager. I started WorkManager when app goes to background. And I also started background service whenever WorkManger is running. I can see my app service after app went background. Also I can see that it is started after about 15 minutes from when I cl...
Young
1

votes
0

answer
201

Views

WorkManager custom URL constraint?

I have been using android-priority-job-queue V2 for 2 years now (great library). Android Workmanager just appeared. What I like about it is that it is really easy to setup and you don't have to fight with the JobScheduler, Firebase JobDispatcher, or AlarmManager, it is done for us. With android-prio...
Maxime Claude
1

votes
1

answer
199

Views

Runtime exception when upgrading WorkManager from 1.0.0-alpha02 to 1.0.0-alpha03

When I upgrade WorkManager from 1.0.0-alpha02 to 1.0.0-alpha03. Old build.gradle def work_version = '1.0.0-alpha02' implementation 'android.arch.work:work-runtime:$work_version' // use -ktx for Kotlin // optional - Firebase JobDispatcher support implementation 'android.arch.work:work-firebase:$work_...
Cheok Yan Cheng
1

votes
0

answer
261

Views

java.lang.IllegalStateException during androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal

We are using the following WorkManager def work_version = '1.0.0-alpha02' implementation 'android.arch.work:work-runtime:$work_version' // use -ktx for Kotlin // optional - Firebase JobDispatcher support implementation 'android.arch.work:work-firebase:$work_version' We not upgraded from 1.0.0-alpha0...
Cheok Yan Cheng
1

votes
0

answer
289

Views

Regarding RETRY value of WorkerResult of WorkManager

I am using WorkManager class for a task that I want my app to do at specific time. My Worker class goes like below. @Override public Result doWork(){ downloadUpdates(); return Result.SUCCESS; } I created this work with OneTimeWorkRequest like below. Constraints.Builder builder = new Constraints.Buil...
musooff
1

votes
1

answer
374

Views

How to get WorkManager always running in background

How do i get WorkManager always running in background, nomatter if app is closed/killed/open, it should always be running. I've code in doWork method that checks for changes in database and sends a notification upon change in database. So, it should always be running in bg to check for changes. So w...
Mukesh
1

votes
0

answer
31

Views

Too many native crashes on Google Play Dev Console

I am seeing too many native crashes on Google Play Dev console. The crashes started coming when I integrated Android WorkManager into my app. Before the WorkManager update, there was not a single native crash with my app, but as of now with current production version I see about 100 native crashes....
Abhishek Batra
0

votes
0

answer
6

Views

Is it better to use multiple workers that perform the same task for inputs or one worker that performs the task multiple times for inputs?

Is it better to use multiple workers that perform the same task for inputs or one worker that performs the task multiple times for inputs? 1 worker : \\\ SomeWorker.class @NonNull @Override public Worker.Result doWork() { Context applicationContext = getApplicationContext(); boolean success = Boolea...
RamPrasadBismil
1

votes
1

answer
394

Views

Androidx workmanager inject with dagger

I am exploring Work manager. But I try to inject with dagger 2.15 I follow this guideline but the problem is DispatchingAndroidInjector is not injecting on Application class. I got this kind of error. kotlin.UninitializedPropertyAccessException: lateinit property workerInjector has not been initial...
Shudipto Trafder
1

votes
0

answer
230

Views

Work manager if connected to WFI and connected to cellular network

In my application, I want to upload files to a server. There are 400- 500 files are there, I am using work manager to upload files on a server. If a user is connected to WIFI I want to upload a single file after every 15 min and if a user is not connected to WIFI but cellular data is present then I...
PPD
1

votes
1

answer
44

Views

Amazon S3 TransferUtility stops when application is closed ,even in WorkManager

I'm using S3 TransferUtility to upload the files, the issue that i'm facing is that it stops uploading when application is closed. I want it to keep uploading running in background, for that purpose i started upload in WorkManager but still it finishes upload. What is the issue? And how is it possib...
Usman Rana
1

votes
0

answer
252

Views

How to Use Work Manager to show notifications at later time

I'm trying to understand how to show a notification at a specific time, I understand that I can use workmanager for this purpose and that it will choose the correct method to do the job (in this case show the notification) even if the app is closed the device reset etc. Now I have a test method that...
Gabriel H
1

votes
1

answer
149

Views

Foreground(/Background) Service Or Geofencing API

I am working on an android app that has to update location every 10 seconds. Means I have to do polling for every 10 seconds when user wanted to do. Which one is better to use Service or Geofencing API. Which will be better for reducing battery draining. Thanks
UserAT152
1

votes
2

answer
99

Views

Cordova + WorkManager exception

I choose WorkManager to make a scheduled service that would help me post data to server when cordova based app is closed. So, I start with including dependencies in build.gradle (Module:app) dependencies { implementation fileTree(dir: 'libs', include: '*.jar') //THIS LINE HERE IS FOR WORKMANAGER i...
wenn32
1

votes
1

answer
295

Views

Is it possible to use WebView in Worker?

Background I'm trying to load some URL in the background, but in the same way WebView loads it in an Activity. There are multiple reasons developers would want it (and requested about it here) , such as running JavaScript without Activity, caching, monitor websites changes, scrapping ... The problem...
android developer
1

votes
1

answer
90

Views

Periodic WorkManager doesn't wait for image download completion to set wallpaper

I'm using Periodic WorkManager but update wallpaper after every x minutes automatically. But the issue that I'm facing is that when 'downloadWallpaper' method is called to download the image, it meanwhile proceeds to next method 'setWallpaper' without waiting for image loading completion. How can I...
Usman Rana
1

votes
1

answer
1.1k

Views

WorkManager : Cannot access database on the main thread since it may potentially lock the UI for a long period of time

I got error when I use WorkManager. Cannot access database on the main thread since it may potentially lock the UI for a long period of time. My Code val x = WorkManager.getInstance().getStatusesByTag(vm.workTag) x.observeForever { } If i dont use method observe all work fine My Log Caused by: j...
1

votes
1

answer
574

Views

Download file using WorkManager

I am working/trying with download a file with pause and resume functionality using WorkManager with MVVM. Here I am seeking pause/resume and download percentage progress update with use of WorkManager. So I am sharing my classes here. MainActivity.kt class MainActivity : AppCompatActivity() { latein...
Karthikeyan Ve
1

votes
1

answer
173

Views

WorkManager 1.0.0-alpha11 not working on API <= 22 when app closes from app list

I am downloading an mp3 file from this URL using HttpURLConnection in doWork override method. Now the problem is download get killed when the app closes from app list in below 22 API devices. Although upper versions of 22 API devices can restart download after closing the app from app list. I hav...
Al-Amin
1

votes
1

answer
256

Views

WorkManager OneTimeWorkRequest InitialDelay works after twise the time set

I'm facing problem with WorkManager OneTimeWorkRequest setInitialDelay. It's work fine when app is in forground or in recent list. But When I remove App from recent list everything is messed up. What I want to achieve ? - I want send notification to user after few hours when some task is pending ,so...
b devloper
1

votes
0

answer
42

Views

WorkManager listen to chained tasks

I see we can check each Worker by using below code: WorkManager.getInstance().getWorkInfoByIdLiveData(compressionWork.id) .observe(lifecycleOwner, Observer { workInfo -> // Do something with the status if (workInfo != null && workInfo.state.isFinished) { // ... } }) But i don't know how to check if...
Admiral Kunkka
1

votes
0

answer
62

Views

WorkManager always in ENQUEUED state (android nougat)

I try this script : var myConstraints = Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build() val uploadInventorySyncWork = OneTimeWorkRequest.Builder(UploadInventorySyncWorker::class.java) .setConstraints(myConstraints) .addTag(UploadInventoryModel.ONE_TIME_TAG) .build() Wor...
Kakashi
1

votes
0

answer
140

Views

Downloading on Android Via Retrofit2 using WorkManager Creating an Extra File Called '2811fb90a1302h'

I've written code to download/upload files using retrofit 2. I'm running it with Work Manager. The code itself works fine. All the files I upload/download go to the appropriate locations, however on both the server I'm uploading to and the phone I'm downloading to files called '2811fb90a1302h' are b...
no1isnothing
1

votes
0

answer
91

Views

Android Work Manager: How to enqueue Jobs once a month

following this question, I looked into Android Job Scheduling and it seems like Work Manager is the latest tool if I want to do something once every month. I built a Worker class and activated it with this snippet in my activity: PeriodicWorkRequest myWorkRequest = new PeriodicWorkRequest.Builder(Mo...
Apfelsaft23
1

votes
1

answer
113

Views

Using Android WorkManager for local Notification instead of AlarmManager

User selects a time to notify a message as a reminder that could repeat for everyday or only on certain day of the week.Previously I did this task by setting time to AlarmManager Calendar calSet= Calendar.getInstance(); //calSet.set(Calendar.DAY_OF_WEEK, dayOfWeek); for a particular day of the week...
ganesh
1

votes
0

answer
158

Views

How can I test Android WorkManager with setRequiredNetworkType(NetworkType.CONNECTED) constraint?

I am trying to write Android instrumentation tests for a class that contains WorkManager WorkRequests. For a long time I was stuck at the point where I could see the workers being enqueued but they never got executed. After some time and trial and error I realised the following constraint was blocki...
Paul
1

votes
0

answer
9

Views

SQLiteException in WorkManager's ForceStopRunnable

I'm using android.arch.work:work-runtime-ktx:1.0.1-rc1 and receiving many SQLiteException which I cannot reproduce. The exception: android.database.sqlite.SQLiteException: at android.database.sqlite.SQLiteConnection.nativeOpen (Native Method) at android.database.sqlite.SQLiteConnection.open (SQLite...
cora32
1

votes
0

answer
30

Views

StorageException on resuming Firebase upload task through WorkManager

I'm running a Firebase upload Task through WorkManager. On regular progress updates from UploadTask, I save the session uri in my Shared Preference. When I switch internet off, Firebase handles the scenario itself and resumes the upload task when internet is turned back on. But when I power off the...
Shivam Gandhi
1

votes
0

answer
42

Views

Can we add another UniqueWork in queue of other UniqueWork with WorkManager

Let say i have started this UniqueWork with WorkManager:- var workContinuation: WorkContinuation = WorkManager.getInstance() .beginUniqueWork(AppConstants.FILE_CREATOR_TAG, ExistingWorkPolicy.APPEND, firstOneTimeWorkRequest) Now at this point, our application user may want to start another UniqueWor...
Herry
1

votes
1

answer
167

Views

Using RxWorker for api calls in WorkManager

I am trying to access the work info of a worker class while using RxWorker. Below is the worker class public class OrderSyncWorker extends RxWorker { @NonNull @Override public Single createWork() { List ordersToBeSynced = databaseRepository.getNonSyncedOrders(); JSONArray orders = new JSONArray(); t...
Nidhin Rejoice
1

votes
0

answer
81

Views

Periodic Work Manager not working in Oreo when Swipe out the app from recent apps

I was implementing the Work Manager.As per documentation, work manager will give the guarantee to execute your task. But When i am using in OREO and swiping out the application from recent apps then work manager is not working. It will be a great help if anyone can suggest me what i am doing the wro...
Shubham Chauhan
1

votes
2

answer
142

Views

Android Jetpack WorkManager - Test UniquePeriodicWork Execution

I am using Android's Jetpack WorkManager to schedule some periodic download tasks once a day. I followed the instructions and get a Success back when the Work is enqueued: val work = PeriodicWorkRequestBuilder(1, TimeUnit.DAYS) .setConstraints(constraints) // Internet connection, idle and battery no...
Spipau
1

votes
2

answer
132

Views

New Android Places SDK in Android Work Manager

To Preface, I'm working in react-native and our app uses a lot of background processes. We've tried a number of react native based solutions like background-fetch, background-geolocation, etc. We've found in testing that the best possible approach for collecting data in background threads is Android...
edwin
1

votes
0

answer
32

Views

Is there any “clean” way to track the progress/intermediate results of a file upload in a WorkManager?

I'm trying to refactor my app to use WorkManager and RxWorker to upload files to the server. I need to track intermediate results of upload and notify observers with current upload progress. So far what I've read is that the Worker can only return a single result or an error when the task is comple...
TheTechWolf
1

votes
1

answer
54

Views

Pre-Populate Room Database using WorkManager and Dagger

I am trying to use WorkManager to populate the Room Database while creating the database. I am using dagger to initialize the database and its Dao's. While seeding the database, it gives the following error. Could not instantiate *.*.*.SeedDatabaseWorker java.lang.NoSuchMethodException: [class andr...
saroj maharjan
1

votes
0

answer
36

Views

Firebase Token ID : When passed via WorkManager Android

The firebase auth token expires after typically an hour. When using Work Manager to Schedule the task to sync the local database with the global, firebase token is sent along with the request. As Workmanager can send the request typically after the expiration of token, how can I handle this situatio...
Akshay Kant

View additional questions