我收到一条错误消息:未解决的引用:mListener
从下面的代码中:
一旦获得第一个修复程序,我想停止locationupdates
。您能帮忙解决吗?
var mManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
var mListener = object : LocationListener {
override fun onLocationChanged(location: Location) {
doSomeWork()
mManager.removeUpdates(mListener)
}
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
}
override fun onProviderEnabled(provider: String?) {
}
override fun onProviderDisabled(provider: String?) {
}
}
mManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0f, mListener)