android-workmanager

Dagger2: Unable to inject dependencies in WorkManager

烈酒焚心 提交于 2019-12-02 19:25:14
So from what I read, Dagger doesn't have support for inject in Worker yet. But there are some workarounds as people suggest. I have tried to do it a number of ways following examples online but none of them work for me. When I don't try to inject anything into the Worker class, the code works fine, only that I can't do what I want because I need access to some DAOs and Services. If I use @Inject on those dependencies, the dependencies are either null or the worker never starts i.e the debugger doesn't even enter the Worker class. For eg I tried doing this: @Component(modules = {Module.class})

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

我是研究僧i 提交于 2019-12-02 17:24:21
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 Dependencies build.gradle(app) apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "rock.dmx.xaro.workmanagerexample" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false

Android Work Manager: How to enqueue Jobs once a month

为君一笑 提交于 2019-12-02 11:36:16
问题 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(MonthlyWorker.class, 20, TimeUnit.MINUTES) .build(); WorkManager.getInstance().enqueueUniquePeriodicWork("my fancy test",ExistingPeriodicWorkPolicy.KEEP, myWorkRequest); While i tested the 20 minutes

Android: Which Background Service to use?

萝らか妹 提交于 2019-12-02 11:34:41
问题 I have an app where a user can perform a backup (offline) and restore (offline) on a button click. However, i don't know which background service is appropriate to use. Can someone advise me whether to use WorkerManager or Service in this case? 回答1: I recommend you to use ForegroundService as of the goal of using these services are Long Running Processes that Users should be informed and interact with it . Consider when you try to backup when you Use ForegroundService then you can show to

Android: Which Background Service to use?

我是研究僧i 提交于 2019-12-02 03:14:35
I have an app where a user can perform a backup (offline) and restore (offline) on a button click. However, i don't know which background service is appropriate to use. Can someone advise me whether to use WorkerManager or Service in this case? Mr.AF I recommend you to use ForegroundService as of the goal of using these services are Long Running Processes that Users should be informed and interact with it . Consider when you try to backup when you Use ForegroundService then you can show to user The process left to end Cancel Backup Pause and etc So I recommend you to use this approach . 来源:

workstatus observer always in enqueued state

有些话、适合烂在心里 提交于 2019-12-02 01:18:27
问题 I am trying to observe my workers but they are always in queued state or sometime it's RUNNING but never SUCCEED or FAILED . is workStatus.state from return in doWork() or it's different? this is my worker script: package com.mockie.daikokuten.sync.workers import androidx.work.Worker class TestWorker:Worker() { override fun doWork():Worker.Result { return Worker.Result.SUCCESS } } this is script to observe the workers : val test = PeriodicWorkRequest.Builder( TestWorker::class.java,

WorkManager OneTimeWorkRequest InitialDelay works after twise the time set

为君一笑 提交于 2019-12-01 12:26:28
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 after some R&D start work using WorkManager because of It's ability to Schedule Tasks without background service limitation. Now below is code snippet which work till app is not removed from recent: Constraints constraints = new Constraints.Builder() .setRequiresBatteryNotLow(true) .build(); final

Periodic daily work requests using WorkManager

前提是你 提交于 2019-11-30 19:35:49
How to properly use the new WorkManager from Android Jetpack to schedule a one per day periodic work that should do some action on a daily basis and exactly one time? The idea was to check if the work with a given tag already exists using WorkManager and to start a new periodic work otherwise. I've tried to do it using next approach: public static final String CALL_INFO_WORKER = "Call worker"; ... WorkManager workManager = WorkManager.getInstance(); List<WorkStatus> value = workManager.getStatusesByTag(CALL_INFO_WORKER).getValue(); if (value == null) { WorkRequest callDataRequest = new

Why backup related process might cause Application's onCreate is not executed?

↘锁芯ラ 提交于 2019-11-30 17:10:55
It is common to have Application class as follow public class WeNoteApplication extends MultiDexApplication { public static WeNoteApplication instance() { return me; } @Override public void onCreate() { super.onCreate(); me = this; During normal circumstance, Application 's onCreate will always be called before entry point Activity 's onCreate. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Normally, it will NOT be null. android.util.Log.i("CHEOK", "WeNoteApplication -> " +

Android Workmanager PeriodicWorkRequest is not unique

断了今生、忘了曾经 提交于 2019-11-30 16:01:41
问题 For OneTimeWorkRequest we can use WorkContinuation to ensure that if the job is already scheduled we can KEEP or REPLACE it. There is no such option for PeriodicWorkRequest, so every time my main activity is created a new job is created and after a while I get this exception. java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs So I'm trying the following to create a "unique peiodic work" public void schedule(){ Constraints constraints = new Constraints.Builder()