Fusedlocationproviderclient With Service Android Kotlin
I am using Fused Api for location update. I am using Fused Api with Activity is working fine. But when i use it within service class its showing This is my Service class code . Wh
Solution 1:
Class Task
(https://developers.google.com/android/reference/com/google/android/gms/tasks/Task) have three overloads of method addOnCompleteListener
:
addOnCompleteListener(OnCompleteListener<TResult> listener)
addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener)
addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener)
Your Service
is neither Activity
, nor Executor
. So the two latter overloads are not applicable for you. Just drop the first parameter and use it like that:
mFusedLocationClient!!.lastLocation.addOnCompleteListener { task ->
//do something
}
Post a Comment for "Fusedlocationproviderclient With Service Android Kotlin"