Loved the pace, not too slow but not making a lot of assumptions about what the viewer might be watching. I've been using WorkManager for some time now and still found the pace on-point! Allowed me to follow with ease. Something I noticed: The mic seems to be attached to the table where the keyboard is, it is a bit annoying to hear the "bumps" especially with headphones. TY for the great content as always.
I'm not sure you picked the correct example. Seems to me that blurring an image is a rarely deferable use case. Explanation was great, that example tho, not sure...
It may not be a deferable use case, but it can take a long time to process the image. So, you can use workmanager to manage the blurring on the background without any kind of risk of the computation been interrupted in the middle and make the app usable while it is processing and saving the image.
hello Sir/Mam work manager is not working in all Chinese Phones Problem is that workManager is only working when app is in foreground or background as soon as user removes app from task manager than the work which I posted in OneTimeRequest or PeriodicRequest it is not running any more. It is working in samsung and emulator but not on realme,readmi,vivo,infinix,xiomi etc chinease mobiles based on android. Please help
@mooingturtle Thanks for the proper guidelines. The way that you have explained about the each features and the code is awesome. The best tutorial video loved it.
Some one can give me a use case where I can't execute a long running task simply using a coroutine instead of work manager? I'm still able to decide which thread to use with coroutines
Corutines uses application lifecycle, while work manager doesn't, managing coroutine can be difficult and as fair threading goes you can use local scoped coroutine or fork pool or parallel work, for any long running task that doesn't require user interaction, work manager and alarm manager (for period task) are best apis
If I start a WorkManager from a service, what will be the App Standby Bucket? I want to write an accessibility tool, which is activated as a service, but my app isn't actively running in the foreground - no activity visible. Now, I'm afraid, if the WorkManager can be deferred up to 24h, which would be a real bad thing.
The app standby bucket depends on your app's usage by the user and not where you start WorkManager from. A11y tools can request exemptions from system battery optimizations.
@@keyboardsurfer So, my app will always be in the worst state, because it’s just a tool running in the background. The UI will be seen only once a month, I believe. That’s bad for the user experience, if you are writing an accessibility tool. Are you sure? And to force the user to exclude my app isn‘t good practice.
@@mars3142 For many apps having the user request the exemption is necessary. When your app runs as accessibility service you get some special permissions, i.e. act on the users behalf. This means it should be treated as being in the foreground.
Because that's what WorkManager requests. The application context lives longer than your activity context. And yes, you should be passing in an application context into your Worker classes as well.
thanks for the video but i run into following problem: in the dowork method i can read firestore document successfully BUT IF I execute code in the onsuccessListener callback it never runs. check the following snippet and please give me some hints . thank you @NonNull @Override public Result doWork() { String firebaseUserId = getInputData().getString("id"); FirebaseFirestore.getInstance().collection("users")document(firebaseUserId).get().addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { Users user = documentSnapshot.toObject(Users.class); //Why following tasks are never executed???? how to solve this problem? // new StoreUserTask(user); //-> this is an AsyncTask // doExecuteInsertUserExecutorTask(user); //-> this call run on Executors.newSingleThreadExecutor(); } }); }
The thing i don't really like about this API is that the data passed around are persisted, so you'll need to handle data migration of risk losing pending work requests
If your app is not running and not restricted by the system or through user's choice, then WorkManager will execute your request on a best effort basis.