반응형

 

위치 정확도란.. GPS 해보면 알다싶이.. 위치가 그렇게 정확하지가 않다.. 

사용자에게 위치 정확도 개선 승인을 받으면 그래도 좀더 정확해진다.. 

나는 onResume에서 계속 확인한다.. 

 

필요한사람은 가져다 쓰도록해요~ ..

	//위치 정확도 개선 요청.
    public void requestGpsSettingChange() {
        LocationRequest request = LocationRequest.create();
        request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        LocationSettingsRequest.Builder builder =
                new LocationSettingsRequest.Builder().addLocationRequest(request);

        Task<LocationSettingsResponse> result = LocationServices
                .getSettingsClient(getApplicationContext())
                .checkLocationSettings(builder.build());

        result.addOnSuccessListener(this, new OnSuccessListener<LocationSettingsResponse>() {
            @Override
            public void onSuccess(LocationSettingsResponse locationSettingsResponse) {

            }
        });

        result.addOnFailureListener(this, new OnFailureListener() {

            @Override
            public void onFailure(@NonNull Exception e) {

                try {
                    // Show the dialog by calling startResolutionForResult(),
                    // and check the result in onActivityResult().
                    ResolvableApiException resolvable = (ResolvableApiException) e;
                    resolvable.startResolutionForResult(MainActivity.this,
                            REQUEST_CHECK_SETTINGS);
                } catch (IntentSender.SendIntentException sendEx) {
                    // Ignore the error.
                }
            }
        });
    }

 

https://developer.android.com/training/location/change-location-settings?hl=ko

반응형

+ Recent posts