如何创建对话框来请求GPS(如Google Maps对话框)

时间:2019-05-06 08:13:56

标签: android google-maps dialog

enter image description here

您好,我有一个代码来创建类似Google Map对话框的对话框, 但我读到LocationServices.SettingsApideprecated。有没有办法更改SettingApi以获得类似于Google Maps的对话框?

mLocationRequest = LocationRequest.create()?.apply {
        interval = 10000
        fastestInterval = 5000
        priority = LocationRequest.PRIORITY_HIGH_ACCURACY
    }!!
    val builder = LocationSettingsRequest.Builder()
            .addLocationRequest(mLocationRequest)
    builder.setAlwaysShow(true)
    val task = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build())
    task.setResultCallback { result ->
        val status = result.status
        when (status.statusCode) {
            LocationSettingsStatusCodes.RESOLUTION_REQUIRED -> try {
                status.startResolutionForResult(mActivity, REQUEST_LOCATION)
            } catch (e: IntentSender.SendIntentException) {
            }

        }
    }

0 个答案:

没有答案