11

Is there a adb shell (dumpsys) command that will give a detailed info of all the tasks scheduled using workmanager - PeriodicWorkRequest

Basically I have a scheduled task which should run daily. How do I get when Is the next task scheduled using adb.

Will adb shell dumpsys alarm package.name list my scheduled work using workmanager

Rinav
  • 2,527
  • 8
  • 33
  • 55
  • https://developer.android.com/topic/libraries/architecture/workmanager/how-to/states-and-observation#observing – pskink Apr 27 '19 at 11:29
  • I know that, I want to get the info using adb so that I can see if I scheduled properly – Rinav Apr 27 '19 at 12:02
  • so override `dump` method like [here](https://stackoverflow.com/a/51915233/2252830) and dump your `WorkInfo` object – pskink Apr 27 '19 at 12:04
  • Interesting, will try and see if I get what I want – Rinav Apr 27 '19 at 12:07

2 Answers2

10

Given that WorkManager stores all the WorkRequest in a Room database, your bet bet is to retrieve that DB and look into it.

For adb as far as I know, your best bet is to use what is available for JobScheduler (that WorkManager uses for API Level 23+ devices):

adb shell dumpsys jobscheduler

as answered here.

Update January 2020 More information on how to debug WorkManager is now available in the official documentation: Debugging WorkManager.

pfmaggi
  • 6,116
  • 22
  • 43
4

Clear your logcat. Open the terminal. Run adb shell am broadcast -a "androidx.work.diagnostics.REQUEST_DIAGNOSTICS" -p "<your_app_package_name>". Check logcat again. This should work.

Rohit P Soman
  • 1,141
  • 12
  • 16