addOnCompleteListener(OnCompleteListener<TResult> listener) addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener) addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener) 您的Service既不是Activity,也不是Executor.因此,后两个重载不适用于您.只需删除第一个参数并像这样使用它即可: mFusedLocationClient!!.lastLocation.addOnCompleteListener { task -> //do something} 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 . Where error occurring 解决方案 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} 这篇关于具有服务Android Kotlin的FusedLocationProviderClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 19:49