如果不发出位置请求,我将无法致电startResolutionForResult()
。我正在使用FusedLocationProvider API
来获取Google Maps V2中的用户位置更新:
val builder = LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest)
val client = LocationServices.getSettingsClient(this)
val task = client!!.checkLocationSettings(builder!!.build())
task!!.addOnSuccessListener {
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper())
val serviceIntent = Intent(this@MainActivity, LocationService::class.java)
startService(serviceIntent)
}.addOnFailureListener { exception ->
if (exception is ResolvableApiException) {
try {
exception.startResolutionForResult(this@MainActivity, 11351)
} catch (throwable: Throwable) {
// Ignore the error.
}
}
}
我想做的是在不发出位置请求的情况下呼叫startResolutionForResult()
。