com.google.android.gms.location.LocationSettingsRequest Java Examples
The following examples show how to use
com.google.android.gms.location.LocationSettingsRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocationSwitch.java From react-native-location-switch with Apache License 2.0 | 6 votes |
public void displayLocationSettingsRequest(final Activity activity) { GoogleApiClient googleApiClient = new GoogleApiClient.Builder(activity) .addApi(LocationServices.API).build(); googleApiClient.connect(); LocationRequest locationRequest = LocationRequest.create(); locationRequest.setPriority(mAccuracy); locationRequest.setInterval(mInterval); locationRequest.setFastestInterval(mInterval / 2); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); builder.setAlwaysShow(false); final PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); result.setResultCallback(new LocationResultCallback(activity)); }
Example #2
Source File: BasePlatformCreate.java From indigenous-android with GNU General Public License v3.0 | 6 votes |
/** * Initiate the location libraries and services. */ private void initLocationLibraries() { mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mSettingsClient = LocationServices.getSettingsClient(this); mLocationCallback = new LocationCallback() { @Override public void onLocationResult(LocationResult locationResult) { super.onLocationResult(locationResult); // location is received mCurrentLocation = locationResult.getLastLocation(); updateLocationUI(); } }; mRequestingLocationUpdates = false; mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); mLocationSettingsRequest = builder.build(); }
Example #3
Source File: MainActivity.java From Android-nRF-BLE-Joiner with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createLocationRequestForResult(){ mLocationRequestBalancedPowerAccuracy = new LocationRequest(); final LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequestBalancedPowerAccuracy) .setAlwaysShow(true); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build()); result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(LocationSettingsResult locationSettingsResult) { Log.v("BLE", locationSettingsResult.getStatus().getStatusMessage()); LocationSettingsStates states = locationSettingsResult.getLocationSettingsStates(); if(states.isLocationUsable()) { checkForLocationPermissionsAndScan(); return; } final Status status = locationSettingsResult.getStatus(); switch(status.getStatusCode()){ case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: mLocationServicesRequestApproved = false; try { status.startResolutionForResult(MainActivity.this, REQUEST_LOCATION_SERVICES); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } break; case LocationSettingsStatusCodes.SUCCESS: mLocationServicesRequestApproved = true; checkForLocationPermissionsAndScan(); break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: showPermissionRationaleFragment(R.string.rationale_location_cancel_message, 0); break; } } }); }
Example #4
Source File: TimeAttendantFastFragment.java From iBeacon-Android with Apache License 2.0 | 5 votes |
private synchronized void displayLocationSettingsRequest() { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest); builder.setAlwaysShow(true); //for fix deprecate code -> https://developers.google.com/android/reference/com/google/android/gms/location/SettingsClient PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); result.setResultCallback(this); }
Example #5
Source File: AndroidLocationProvider.java From BLE-Indoor-Positioning with Apache License 2.0 | 5 votes |
private void setupLocationService() { Log.v(TAG, "Setting up location service"); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(getLocationRequest()); SettingsClient client = LocationServices.getSettingsClient(activity); Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build()); task.addOnSuccessListener(activity, new OnSuccessListener<LocationSettingsResponse>() { @Override public void onSuccess(LocationSettingsResponse locationSettingsResponse) { Log.v(TAG, "Location settings satisfied"); } }); task.addOnFailureListener(activity, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: Log.w(TAG, "Location settings not satisfied, attempting resolution intent"); try { ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(activity, REQUEST_CODE_LOCATION_SETTINGS); } catch (IntentSender.SendIntentException sendIntentException) { Log.e(TAG, "Unable to start resolution intent"); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: Log.w(TAG, "Location settings not satisfied and can't be changed"); break; } } }); }
Example #6
Source File: LocationProvider.java From LocationAware with Apache License 2.0 | 5 votes |
public void setUpLocationRequest(OnSuccessListener<LocationSettingsResponse> successListener, OnFailureListener onFailureListener) { LocationRequest locationRequest = getLocationRequest(); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest); SettingsClient settingsClient = LocationServices.getSettingsClient(context); Task<LocationSettingsResponse> locationSettingsResponseTask = settingsClient.checkLocationSettings(builder.build()); locationSettingsResponseTask.addOnSuccessListener(successListener); locationSettingsResponseTask.addOnFailureListener(onFailureListener); }
Example #7
Source File: MainActivity.java From android-rxlocationsettings with Apache License 2.0 | 5 votes |
private void ensureLocationSettings() { LocationSettingsRequest locationSettingsRequest = new LocationSettingsRequest.Builder() .addLocationRequest(LocationRequest.create().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)) .build(); RxLocationSettings.with(this).ensure(locationSettingsRequest) .subscribe(new Action1<Boolean>() { @Override public void call(Boolean enabled) { Toast.makeText(MainActivity.this, enabled ? "Enabled" : "Failed", Toast.LENGTH_LONG).show(); } }); }
Example #8
Source File: RxLocationSettings.java From android-rxlocationsettings with Apache License 2.0 | 5 votes |
@NonNull public Single<Boolean> ensure(@NonNull LocationSettingsRequest request) { return rxLocationProvider.checkLocationSettings(request).toSingle() .flatMap(new Func1<LocationSettingsResult, Single<Boolean>>() { @Override public Single<Boolean> call(LocationSettingsResult result) { Status status = result.getStatus(); if (status.hasResolution()) { return resolutionFragment.startResolutionForResult(status.getResolution()); } return Single.just(status.isSuccess()); } }); }
Example #9
Source File: MyLocationMapActivity.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
/** * This turns on Wifi/cell location tracking using Google Play services * It shows a dismissible dialog for users that don't have location already enabled */ @SuppressLint("MissingPermission") public void turnOnLocation() { LocationRequest locationRequest = LocationRequest.create(); locationRequest.setInterval(500); locationRequest.setFastestInterval(250); locationRequest.setPriority(Utils.useGPSForLocation(this) ? LocationRequest.PRIORITY_HIGH_ACCURACY : LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); LocationSettingsRequest settingsRequest = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest) .setAlwaysShow(true) .build(); Task<LocationSettingsResponse> task = LocationServices.getSettingsClient(this).checkLocationSettings(settingsRequest); task.addOnSuccessListener(this, locationSettingsResponse -> { goToLastLocation(false); }); task.addOnFailureListener(this, e -> { if (e instanceof ResolvableApiException) { if (isLocationDialogShowing) { return; } // Location settings are not satisfied, but this can be fixed // by showing the user a dialog. try { // Show the dialog by calling startResolutionForResult(), // and check the result in onActivityResult(). ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(MyLocationMapActivity.this, REQUEST_TURN_ON_LOCATION); isLocationDialogShowing = true; } catch (IntentSender.SendIntentException sendEx) { // Ignore the error. } } }); }
Example #10
Source File: MainActivity.java From Android-Fused-location-provider-example with Apache License 2.0 | 5 votes |
private void startLocationUpdates() { Log.i(TAG, "startLocationUpdates"); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); // 現在位置の取得の前に位置情報の設定が有効になっているか確認する PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build()); result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(@NonNull LocationSettingsResult locationSettingsResult) { final Status status = locationSettingsResult.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: // 設定が有効になっているので現在位置を取得する if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, MainActivity.this); } break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: // 設定が有効になっていないのでダイアログを表示する try { status.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS); } 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; } } }); }
Example #11
Source File: BaseNiboFragment.java From Nibo with MIT License | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mGoogleApiClient = injection.getGoogleApiClient(); mLocationRequest = injection.getLocationRequest(); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity()); mSettingsClient = LocationServices.getSettingsClient(getActivity()); mLocationSettingsRequest = builder.build(); // Kick off the process of building the LocationCallback, LocationRequest, and // LocationSettingsRequest objects. createLocationCallback(); this.mCenterMyLocationFab = (FloatingActionButton) view.findViewById(R.id.center_my_location_fab); this.mCenterMyLocationFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initMap(); } }); Bundle args = getArguments(); if (getArguments() != null) { mStyleEnum = (NiboStyle) args.getSerializable(NiboConstants.STYLE_ENUM_ARG); mStyleFileID = args.getInt(NiboConstants.STYLE_FILE_ID); } }
Example #12
Source File: SettingsManager.java From ground-android with Apache License 2.0 | 5 votes |
/** * Try to enable location settings. If location settings are already enabled, this will complete * immediately on subscribe. */ public Completable enableLocationSettings(LocationRequest locationRequest) { Log.d(TAG, "Checking location settings"); LocationSettingsRequest settingsRequest = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest).build(); return settingsClient .checkLocationSettings(settingsRequest) .toCompletable() .onErrorResumeNext(t -> onCheckSettingsFailure(LOCATION_SETTINGS_REQUEST_CODE, t)); }
Example #13
Source File: EasyWayLocation.java From EasyWayLocation with Apache License 2.0 | 5 votes |
private void checkLocationSetting(){ LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.setAlwaysShow(true); builder.addLocationRequest(locationRequest); SettingsClient client = LocationServices.getSettingsClient(context); Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build()); task.addOnSuccessListener(locationSettingsResponse -> { if (mRequireLastLocation){ beginUpdates(); endUpdates(); }else { beginUpdates(); } }); task.addOnFailureListener(e -> { if (e instanceof ResolvableApiException) { // Location settings are not satisfied, but this can be fixed // by showing the user a dialog. try { // Show the dialog by calling startResolutionForResult(), // and check the result in onActivityResult(). ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult((Activity)context, LOCATION_SETTING_REQUEST_CODE); } catch (IntentSender.SendIntentException sendEx) { sendEx.printStackTrace(); } } }); }
Example #14
Source File: RNFusedLocationModule.java From react-native-geolocation-service with MIT License | 5 votes |
/** * Build location setting request using current configuration */ private LocationSettingsRequest buildLocationSettingsRequest() { mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(mLocationPriority) .setInterval(mUpdateInterval) .setFastestInterval(mFastestInterval) .setSmallestDisplacement(mDistanceFilter); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); return builder.build(); }
Example #15
Source File: NearByHospitalActivity.java From BloodBank with GNU General Public License v3.0 | 5 votes |
@Override public void onConnected(@Nullable Bundle bundle) { locationRequest = new LocationRequest(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(locationRequest); LocationSettingsRequest locationSettingsRequest = builder.build(); SettingsClient settingsClient = LocationServices.getSettingsClient(getActivity()); settingsClient.checkLocationSettings(locationSettingsRequest); if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Toast.makeText(getActivity(), "You need to enable permissions to display location !", Toast.LENGTH_SHORT).show(); } fusedLocationProviderClient.getLastLocation().addOnSuccessListener(getActivity(), new OnSuccessListener<Location>() { @Override public void onSuccess(Location location) { ShowHospitals(location.getLatitude(), location.getLongitude()); } }); }
Example #16
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onConnected(Bundle bundle) { wasConnectedToPlayServices = true; try { if (Build.VERSION.SDK_INT >= 21) { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); result.setResultCallback(locationSettingsResult -> { final Status status = locationSettingsResult.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: startFusedLocationRequest(true); break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: Utilities.stageQueue.postRunnable(() -> { if (lookingForPeopleNearby || !sharingLocations.isEmpty()) { AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.needShowPlayServicesAlert, status)); } }); break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: Utilities.stageQueue.postRunnable(() -> { playServicesAvailable = false; try { googleApiClient.disconnect(); start(); } catch (Throwable ignore) { } }); break; } }); } else { startFusedLocationRequest(true); } } catch (Throwable e) { FileLog.e(e); } }
Example #17
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
public Completable checkAndHandleResolutionCompletable(@NonNull LocationSettingsRequest locationSettingsRequest, long timeoutTime, @NonNull TimeUnit timeoutUnit) { return checkAndHandleResolutionInternal(locationSettingsRequest, timeoutTime, timeoutUnit).flatMapCompletable(CHECK_SETTINGS_COMPLETABLE_FUNCTION); }
Example #18
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
private Single<Boolean> checkAndHandleResolutionInternal(LocationSettingsRequest locationSettingsRequest, Long timeoutTime, TimeUnit timeoutUnit) { return Single.create(new SettingsCheckHandleSingleOnSubscribe(rxLocation, locationSettingsRequest, timeoutTime, timeoutUnit)); }
Example #19
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
public Single<Boolean> checkAndHandleResolution(@NonNull LocationSettingsRequest locationSettingsRequest, long timeoutTime, @NonNull TimeUnit timeoutUnit) { return checkAndHandleResolutionInternal(locationSettingsRequest, timeoutTime, timeoutUnit); }
Example #20
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
LocationSettingsRequest.Builder getLocationSettingsRequestBuilder() { return new LocationSettingsRequest.Builder(); }
Example #21
Source File: LocationAvailableAsyncEmitter.java From Forage with Mozilla Public License 2.0 | 4 votes |
@Override public void call(AsyncEmitter<Void> locationAsyncEmitter) { GoogleApiClient.OnConnectionFailedListener onConnectionFailedListener = connectionResult -> locationAsyncEmitter.onError(new LocationUnavailableException("Failed to connect to Google Play Services!")); ResultCallback<LocationSettingsResult> pendingResultCallback = locationSettingsResult -> { Status status = locationSettingsResult.getStatus(); if (status.getStatusCode() == LocationSettingsStatusCodes.SUCCESS) { locationAsyncEmitter.onCompleted(); } else { locationAsyncEmitter.onError(new LocationUnavailableException("Location services not enabled!")); } }; GoogleApiClient.ConnectionCallbacks connectionCallbacks = new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(@Nullable Bundle bundle) { try { LocationRequest request = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(request) .setAlwaysShow(true); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); result.setResultCallback(pendingResultCallback); } catch (SecurityException e) { locationAsyncEmitter.onError(new LocationUnavailableException("Location permission not available?")); } } @Override public void onConnectionSuspended(int i) { locationAsyncEmitter.onError(new LocationUnavailableException("Connection lost to Google Play Services")); } }; googleApiClient.registerConnectionCallbacks(connectionCallbacks); googleApiClient.registerConnectionFailedListener(onConnectionFailedListener); googleApiClient.connect(); locationAsyncEmitter.setCancellation(() -> { googleApiClient.unregisterConnectionCallbacks(connectionCallbacks); googleApiClient.unregisterConnectionFailedListener(onConnectionFailedListener); }); }
Example #22
Source File: SamLocationRequestService.java From SamLocationAndGeocoding with MIT License | 4 votes |
private void setGoogleClient(){ 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); //this is the key ingredient //************************** Task<LocationSettingsResponse> result = LocationServices.getSettingsClient(context).checkLocationSettings( builder.build()); result.addOnFailureListener((Activity) context, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); if (statusCode == LocationSettingsStatusCodes .RESOLUTION_REQUIRED) { // Location settings are not satisfied, but this can // be fixed by showing the user a dialog try { // Show the dialog by calling // startResolutionForResult(), and check the // result in onActivityResult() ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult ((Activity) context, REQUEST_CODE); } catch (IntentSender.SendIntentException sendEx) { // Ignore the error } } } }); result.addOnSuccessListener((Activity) context, new OnSuccessListener<LocationSettingsResponse>() { @Override public void onSuccess(LocationSettingsResponse locationSettingsResponse) { startLocationUpdates(); } }); }
Example #23
Source File: SettingsApiImpl.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
@Override public PendingResult<LocationSettingsResult> checkLocationSettings(GoogleApiClient client, LocationSettingsRequest locationSettingsRequest) { return new InstantPendingResult<LocationSettingsResult>(new LocationSettingsResult(Status.CANCELED)); }
Example #24
Source File: LocationGetLocationActivity.java From coursera-android with MIT License | 4 votes |
private void continueAcquiringLocations() { // Start location services mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(POLLING_FREQ); mLocationRequest.setFastestInterval(FASTEST_UPDATE_FREQ); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); // Used if needed to turn on settings related to location services SettingsClient client = LocationServices.getSettingsClient(this); Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build()); task.addOnSuccessListener(this, new OnSuccessListener<LocationSettingsResponse>() { @Override public void onSuccess(LocationSettingsResponse locationSettingsResponse) { // All location settings are satisfied. The client can initialize location requests here. if (checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mLocationCallback = getLocationCallback(); mLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null); // Schedule a runnable to stop location updates after a period of time Executors.newScheduledThreadPool(1).schedule(new Runnable() { @Override public void run() { mLocationClient.removeLocationUpdates(mLocationCallback); } }, MEASURE_TIME, TimeUnit.MILLISECONDS); } } }); task.addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: // Location settings are not satisfied, but this can be fixed // by showing the user a dialog. try { // Show the dialog by calling startResolutionForResult(), // and check the result in onActivityResult(). ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(LocationGetLocationActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { // 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; } } }); }
Example #25
Source File: GoogleLocationManagerServiceImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 4 votes |
@Override public void requestLocationSettingsDialog(LocationSettingsRequest settingsRequest, ISettingsCallbacks callback, String packageName) throws RemoteException { Log.d(TAG, "requestLocationSettingsDialog: " + settingsRequest); PackageUtils.getAndCheckCallingPackage(context, packageName); callback.onLocationSettingsResult(new LocationSettingsResult(new LocationSettingsStates(true, true, false, true, true, false), Status.SUCCESS)); }
Example #26
Source File: MainActivity.java From location-samples with Apache License 2.0 | 4 votes |
/** * Uses a {@link com.google.android.gms.location.LocationSettingsRequest.Builder} to build * a {@link com.google.android.gms.location.LocationSettingsRequest} that is used for checking * if a device has the needed location settings. */ private void buildLocationSettingsRequest() { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); mLocationSettingsRequest = builder.build(); }
Example #27
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
public Single<Boolean> checkAndHandleResolution(@NonNull LocationSettingsRequest locationSettingsRequest) { return checkAndHandleResolutionInternal(locationSettingsRequest, null, null); }
Example #28
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
public Completable checkAndHandleResolutionCompletable(@NonNull LocationSettingsRequest locationSettingsRequest) { return checkAndHandleResolutionInternal(locationSettingsRequest, null, null).flatMapCompletable(CHECK_SETTINGS_COMPLETABLE_FUNCTION); }
Example #29
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
private Single<LocationSettingsResult> checkInternal(LocationSettingsRequest locationSettingsRequest, Long timeoutTime, TimeUnit timeoutUnit) { return Single.create(new SettingsCheckSingleOnSubscribe(rxLocation, locationSettingsRequest, timeoutTime, timeoutUnit)); }
Example #30
Source File: LocationSettings.java From RxGps with Apache License 2.0 | 4 votes |
public Single<LocationSettingsResult> check(@NonNull LocationSettingsRequest locationSettingsRequest, long timeoutTime, @NonNull TimeUnit timeoutUnit) { return checkInternal(locationSettingsRequest, timeoutTime, timeoutUnit); }