BirjuVachhani / locus-android

An Awesome Kotlin Location library to retrieve location merely in 3 lines of code
https://birju.dev/posts/retrieve-location-in-just-3-lines-android/
Apache License 2.0
358 stars 40 forks source link

Cannot get latest location from fun getCurrentLocation(context: Context,onResult: (LocusResult) -> Unit) #85

Open mary-ng5519 opened 1 year ago

mary-ng5519 commented 1 year ago

the API doesnt support for threadings from androidx.work, we tried async{}, runBlocking{} but it doest help, the API runs async in the underlying thread Cannot get latest location from fun getCurrentLocation(context: Context,onResult: (LocusResult) -> Unit)

class MyWorker(mContext: Context, workerParameters: WorkerParameters) :
    Worker(mContext, workerParameters) {
  override fun doWork(): Result {
Locus.getCurrentLocation(applicationContext) { result ->
                    result.location!!.let {
//none of values retrived
}
}
  }
}

Please help support API return in future/promises