android-workmanager

How can location updates from FusedLocationProviderClient be processed with Work Manager?

这一生的挚爱 提交于 2019-11-28 12:36:49
First of all, I'm a total Android noob. Have looked for solutions for some time now, but can't find any helpful hints in the right direction so far. This might be generally caused by the nature of the issue itself, being quite niche. The working code below is based on a code lab at https://codelabs.developers.google.com/codelabs/realtime-asset-tracking . I was wondering though, since it was mentioned within several resources as the preferred way now, how you'd do something like that based on Android's Work Manager instead of a Service with an ongoing notification? public class TrackerService

Android WorkManager api for running daily task in Background

眉间皱痕 提交于 2019-11-28 09:54:15
I need to call one API daily in the background even if the app is closed. I have seen about WorkManager API. For my scenario, I tried PeriodicWorkRequest but unfortunately, it's not working as my expected result. What I did is I used this code in the Application class PeriodicWorkRequest.Builder myWorkBuilder = new PeriodicWorkRequest.Builder(MyWorker.class, 24, TimeUnit.HOURS); PeriodicWorkRequest myWork = myWorkBuilder.build(); WorkManager.getInstance().enqueue(myWork); But it's running repeatedly for 11 times when the app is open for the first time after that, it's not running after 24 hrs.

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

痞子三分冷 提交于 2019-11-27 19:37:02
I am trying to use WorkManager 1.0.0-alpha09. I am getting this error: Program type already present: com.google.common.util.concurrent.ListenableFuture Message{kind=ERROR, text=Program type already present: com.google.common.util.concurrent.ListenableFuture, sources=[Unknown source file], tool name=Optional.of(D8)} If i use version 1.0.0-alpha08 or less. I don't get this error but i need public constructor public Worker (Context context, WorkerParameters workerParams) In my case, I had to add the following configurations to app's module build.gradle : configurations { all*.exclude group: 'com

Check if WorkManager is scheduled already

柔情痞子 提交于 2019-11-27 15:02:28
问题 How can I check if WorkManager is scheduled already. Here is my code that schedule WorkManager . public static void scheduleWork() { PeriodicWorkRequest.Builder photoCheckBuilder = new PeriodicWorkRequest.Builder(WorkManagerService.class, TIME_INTERVAL_IN_SECONDS, TimeUnit.SECONDS); PeriodicWorkRequest photoCheckWork = photoCheckBuilder.build(); WorkManager instance = WorkManager.getInstance(); if (instance != null) { instance.enqueueUniquePeriodicWork("TAG", ExistingPeriodicWorkPolicy.KEEP ,

Proper way to tackle and resolve “Excessive network usage (background)”

痴心易碎 提交于 2019-11-27 13:55:04
问题 Problem Background Currently, we have facing " Excessive network usage (background) " from Android Vital report. Last 30 days is 0.04% , but we're only Better than 9% Last 30 days - 0.04% Benchmark - Better than 9% Since only better than 9% looks like a scary thing. We decide to look into this issue seriously. The app is a note taking app (https://play.google.com/store/apps/details?id=com.yocto.wenote), which provides an optional feature - sync to cloud in background after the app close. This

How can location updates from FusedLocationProviderClient be processed with Work Manager?

我怕爱的太早我们不能终老 提交于 2019-11-27 06:13:05
问题 First of all, I'm a total Android noob. Have looked for solutions for some time now, but can't find any helpful hints in the right direction so far. This might be generally caused by the nature of the issue itself, being quite niche. The working code below is based on a code lab at https://codelabs.developers.google.com/codelabs/realtime-asset-tracking. I was wondering though, since it was mentioned within several resources as the preferred way now, how you'd do something like that based on

Android WorkManager api for running daily task in Background

匆匆过客 提交于 2019-11-27 03:17:14
问题 I need to call one API daily in the background even if the app is closed. I have seen about WorkManager API. For my scenario, I tried PeriodicWorkRequest but unfortunately, it's not working as my expected result. What I did is I used this code in the Application class PeriodicWorkRequest.Builder myWorkBuilder = new PeriodicWorkRequest.Builder(MyWorker.class, 24, TimeUnit.HOURS); PeriodicWorkRequest myWork = myWorkBuilder.build(); WorkManager.getInstance().enqueue(myWork); But it's running

Asynchronous Worker in Android WorkManager

僤鯓⒐⒋嵵緔 提交于 2019-11-27 02:04:16
问题 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 a network service call using Retrofit. I know I can make a synchronous network request, but it would block the thread and just feels wrong. Is there any solution for this or it is just not supported at the moment? 回答1: Per WorkManager docs: By

Android Work Manager vs Services?

淺唱寂寞╮ 提交于 2019-11-27 01:20:49
问题 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 classes. What are the pros and cons of Work Manager over regular intent services? Should i switch to work manager now considering the fact that i may have to write more intent services in the future? Also which option would help me test the code

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

我与影子孤独终老i 提交于 2019-11-26 19:56:08
问题 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: com.google.common.util.concurrent.ListenableFuture, sources=[Unknown source file], tool name=Optional.of(D8)} If i use version 1.0.0-alpha08 or less. I don't get this error, but i need public constructor public Worker(Context context, WorkerParameters workerParams) 回答1: Take a look at https