com.google.android.gms.location.LocationAvailability Java Examples
The following examples show how to use
com.google.android.gms.location.LocationAvailability.
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: RNFusedLocationModule.java From react-native-geolocation-service with MIT License | 7 votes |
/** * Get periodic location updates based on the current location request. */ private void getLocationUpdates() { if (mFusedProviderClient != null && mLocationRequest != null) { mLocationCallback = new LocationCallback() { @Override public void onLocationAvailability(LocationAvailability locationAvailability) { if (!locationAvailability.isLocationAvailable()) { invokeError( LocationError.POSITION_UNAVAILABLE.getValue(), "Unable to retrieve location", false ); } } @Override public void onLocationResult(LocationResult locationResult) { Location location = locationResult.getLastLocation(); invokeSuccess(LocationUtils.locationToMap(location), false); } }; mFusedProviderClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null); } }
Example #2
Source File: LocationProvider.java From open-location-code with Apache License 2.0 | 6 votes |
@Override public void onConnected(Bundle bundle) { Log.i(TAG, "Connected to location services"); LocationAvailability locationAvailability = mFusedLocationProviderApi.getLocationAvailability(mGoogleApiClient); if (!locationAvailability.isLocationAvailable()) { mLocationCallback.handleLocationNotAvailable(); return; } Location lastKnownLocation = mFusedLocationProviderApi.getLastLocation(mGoogleApiClient); mFusedLocationProviderApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); if (lastKnownLocation != null) { Log.i(TAG, "Received last known location: " + lastKnownLocation); mCurrentBestLocation = lastKnownLocation; if (mBearing != null) { mCurrentBestLocation.setBearing(mBearing); } mLocationCallback.handleNewLocation(mCurrentBestLocation); } }
Example #3
Source File: GeofenceReceiver.java From android-sdk with MIT License | 6 votes |
private void handleLocationUpdate(Context context, Intent intent) { LocationResult result = LocationResult.extractResult(intent); LocationAvailability availability = LocationAvailability.extractLocationAvailability(intent); Intent service = SensorbergServiceIntents.getServiceIntentWithMessage( context, SensorbergServiceMessage.MSG_LOCATION_UPDATED); if (result != null) { Location location = result.getLastLocation(); if (location != null) { service.putExtra(SensorbergServiceMessage.EXTRA_LOCATION, location); } } if (availability != null) { service.putExtra(SensorbergServiceMessage.EXTRA_LOCATION_AVAILABILITY, availability.isLocationAvailable()); } if (result != null || availability != null) { context.startService(service); } else { Logger.log.geofenceError("Received invalid location update", null); } }
Example #4
Source File: LocationAvailabilitySingleOnSubscribe.java From RxGps with Apache License 2.0 | 5 votes |
@Override protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter<Boolean> emitter) { //noinspection MissingPermission LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(apiClient); if (locationAvailability != null) { emitter.onSuccess(locationAvailability.isLocationAvailable()); } else { emitter.onSuccess(false); } }
Example #5
Source File: GglMapLocationManager.java From FimiX8-RE with MIT License | 4 votes |
public void onLocationAvailability(LocationAvailability locationAvailability) { Log.i("位置", "onLocationAvailability: isLocationAvailable = " + locationAvailability.isLocationAvailable()); }
Example #6
Source File: RxLocationCallback.java From ground-android with Apache License 2.0 | 4 votes |
@Override public void onLocationAvailability(LocationAvailability locationAvailability) { // This happens sometimes when GPS signal is temporarily lost. }
Example #7
Source File: LocationAwareService.java From LocationAware with Apache License 2.0 | 4 votes |
@Override public void onLocationAvailability(LocationAvailability locationAvailability) { Log.i("Debug ", "On Location availability"); }
Example #8
Source File: FusedLocationModule.java From react-native-fused-location with MIT License | 4 votes |
@SuppressWarnings("All") @ReactMethod public void getFusedLocation(boolean forceNewLocation, final Promise promise) { try { if (!areProvidersAvailable()) { promise.reject(TAG, ERROR_NO_LOCATION_PROVIDER); return; } if (!checkForPlayServices()) { promise.reject(TAG, ERROR_PLAY_SERVICES_NOT_FOUND); return; } if (ActivityCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { promise.reject(TAG, ERROR_UNAUTHORIZED); return; } final GoogleApiClient googleApiClient; LocationRequest request = buildLR(); googleApiClient = new GoogleApiClient.Builder(getReactApplicationContext()) .addApi(LocationServices.API) .build(); googleApiClient.blockingConnect(); final Location location; if (!forceNewLocation) { location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); } else { location = null; } if (location == null) { LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, new LocationCallback() { @Override public void onLocationResult(LocationResult locationResult) { super.onLocationResult(locationResult); promise.resolve(convertLocationToJSON(locationResult.getLastLocation())); } @Override public void onLocationAvailability(LocationAvailability locationAvailability) { super.onLocationAvailability(locationAvailability); LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this); googleApiClient.disconnect(); if (!locationAvailability.isLocationAvailable()) { promise.reject(TAG, "Location not available. Does your phone have GPS turned on and internet connectivity?"); } } }, null); return; } promise.resolve(convertLocationToJSON(location)); googleApiClient.disconnect(); } catch (Exception ex) { Log.e(TAG, "Native Location Module ERR - " + ex.toString()); promise.reject(TAG, ex.toString()); } }
Example #9
Source File: SamLocationRequestService.java From SamLocationAndGeocoding with MIT License | 4 votes |
@Override public void onLocationAvailability(LocationAvailability locationAvailability) { super.onLocationAvailability(locationAvailability); Log.e("tag","isavail "+locationAvailability.isLocationAvailable()); }
Example #10
Source File: GoogleLocationManagerServiceImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 4 votes |
@Override public LocationAvailability getLocationAvailabilityWithPackage(String packageName) throws RemoteException { Log.d(TAG, "getLocationAvailabilityWithPackage: " + packageName); PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); return new LocationAvailability(); }
Example #11
Source File: AndroidLocationPlayServiceManager.java From CodenameOne with GNU General Public License v2.0 | 2 votes |
public void onLocationAvailability(LocationAvailability var1) { }