Pro Android with Kotlin
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
179
CHAPTER 8: APIs The requested interval in milliseconds. This setting is only approximate. priority The requested accuracy. This setting influences the battery usage. The following are possible values (constants from LocationRequest): PRIORITY_NO_POWER: Fetches passive updates only if other requestors actively request updates PRIORITY_LOW_POWER: Updates only on “city” levels PRIORITY_BALANCED_POWER_ACCURACY: Updates only on “city street block” levels PRIORITY_HIGH_ACCURACY: Uses the highest possible accuracy available This value will be internally adapted according to available permissions. smallestDisplacement This is the smallest displacement in meters necessary for an update message to be fired. With that location request setting, we check whether the system is able to fulfill our request. This happens in the following code snippet: val REQUEST_CHECK_STATE = 12300 // any suitable ID val builder = LocationSettingsRequest.Builder() .addLocationRequest(reqSetting) val client = LocationServices.getSettingsClient(this) client.checkLocationSettings(builder. build()). addOnCompleteListener { task -> try { val state: LocationSettingsStates = task.result. locationSettingsStates Log.e("LOG", "LocationSettings: \n" + " BLE present: ${state.isBlePresent} \n" + " BLE usable: ${state.isBleUsable} \n" + " GPS present: ${state.isGpsPresent} \n" + " GPS usable: ${state.isGpsUsable} \n" + " Location present: " + "${state.isLocationPresent} \n" + " Location usable: " + "${state.isLocationUsable} \n" + " Network Location present: " + "${state.isNetworkLocationPresent} \n" + " Network Location usable: " + "${state.isNetworkLocationUsable} \n" ) } catch (e: RuntimeExecutionException) { if (e.cause is ResolvableApiException) (e.cause as ResolvableApiException). startResolutionForResult( |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling