prithvibhola / WorkManager

A simple example to demonstrate the working of the Work Manager.
46 stars 18 forks source link

Location not tracking #2

Open coldembrace opened 4 years ago

coldembrace commented 4 years ago

Hello. Thanks for your work. Just built your project and seems like its not working anymore on the newer versions of Android (8.1 real device, 9.0 emulator). What I've done:

  1. Changed kotlin version in build.gradle: 'kotlin': '1.3.50'
  2. Changed btnTrack.setOnClickListener { getFromLocationWithPermissionCheck() } to btnTrack.setOnClickListener { getFromLocation() } in MainActivity (misstype in the function's name).
  3. Changed track time interval to 10 seconds in MainViewModel: val locationWorker = PeriodicWorkRequestBuilder<TrackLocationWorker>(10, TimeUnit.SECONDS).addTag(LOCATION_WORK_TAG).build() so I could test it properly.

But tracking is not working neither when app is running nor when it's closed (it works only once just after the click on a corresponding button). The status of manager is always "ENQUENUED", and there's only 1 message in the Logcat: I/WorkerWrapper: Worker result SUCCESS for Work [ id=c9848574-6e01-4d83-917b-5f7590cc8f25, tags={ prithvi.io.workmanager.utility.workmanager.TrackLocationWorker, LOCATION_WORK_TAG } ] Appreciate any suggestions!

GarviShah commented 3 years ago

Hello, I also find the same issue. Can you please help us to solve this issue?

Your help will be appreciated.

aminsepahan commented 2 years ago

The minimum interval for work manager is 15 minutes, so even if you set it to 10 seconds it does not work Also, this app needs to request background location access permission for android above 29