nullの場合にのみ再作成するので、毎回LocationSettingsRequest.Builder
を再作成しないという問題があるようです。
Android 4.4.4と6.0.1の両方で動作確認済みです。
ダイアログが(場所がボタンを押す間のデバイス上で無効にされたこと提供)ボタンを押すたびに表示され
:
サービスがアプリで使用しているのGoogle Playのバージョンは何
public void checkLocationSetting() {
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(30 * 1000);
mLocationRequest.setFastestInterval(5 * 1000);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
builder.setAlwaysShow(true);
result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
//...
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
// a dialog.
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult(
MainActivity.this,
REQUEST_LOCATION);
} catch (IntentSender.SendIntentException e) {
// Ignore the error.
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way to fix the
// settings so we won't show the dialog.
//...
break;
}
}
});
}
、そしてどのバージョンテスト中にGoogle Playサービスをインストールしたことがありますか? –
私のデバイスで私はGoogleプレイサービス9.2.56を持っていて、私のアプリでは9.0.2を使用しています。 –
@DanielNugent今、最新の9.2.0バージョンを使用するようにアプリケーションを更新しようとしました。まだ同じ問題 –