Java 类com.google.android.gms.location.LocationAvailability 实例源码

项目:RxTask    文件:RxFusedLocationProviderClient.java   
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Observable<LocationAvailability> requestLocationAvailabilityUpdates(LocationRequest
                                                                                   request) {
    return ObservableTask.create(callback -> {
        LocationCallback resultCallback = new LocationCallback() {
            @Override
            public void onLocationAvailability(LocationAvailability locationAvailability) {
                super.onLocationAvailability(locationAvailability);
                callback.onNext(locationAvailability);
            }
        };
        callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
        return client.requestLocationUpdates(request, resultCallback, null);

    });
}
项目:Android-BluetoothSPPLibrary-master    文件:RSSPullService.java   
public void SendLocation(){
    try {
        LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        if (locationAvailability.isLocationAvailable()) {
            // Call Location Services
            LocationRequest locationRequest = new LocationRequest()
                    .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                    .setInterval(10000)//10second
                    .setFastestInterval(5000);//5second
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
            Log.v("SendLocation",locationAvailability.toString());
        } else {
            // Do something when Location Provider not available
            Toast.makeText(getApplicationContext()
                    , "Please Open Location Provider"
                    , Toast.LENGTH_SHORT).show();
        }
    }
    catch (Exception e){
        Log.v("SendLocation exception",e.toString());
    }
}
项目:RxJava2-weather-example    文件:LocationAvailabilitySingleOnSubscribe.java   
@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);
    }
}
项目:RxTask    文件:RxFusedLocationProviderClient.java   
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Maybe<LocationAvailability> getLocationAvailability() {
    return MaybeTask.create(() -> client.getLocationAvailability());
}
项目:RxTask    文件:RequestLocationAvailabilityObservable.java   
@SuppressLint("MissingPermission")
@Override
protected Task<Void> run(ObservableTaskCallback<LocationAvailability> callback) {
    ResultCallback resultCallback = new ResultCallback(callback);
    callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
    return client.requestLocationUpdates(this.request, resultCallback, null);
}
项目:RxGps    文件:LocationAvailabilitySingleOnSubscribe.java   
@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);
    }
}
项目:LocationAssistant    文件:LocationAssistant.java   
private boolean checkLocationAvailability() {
    if (!googleApiClient.isConnected() || !permissionGranted) return false;
    try {
        LocationAvailability la = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        return (la != null && la.isLocationAvailable());
    } catch (SecurityException e) {
        if (!quiet)
            Log.e(getClass().getSimpleName(), "Error while checking location availability:\n " + e.toString());
        if (listener != null)
            listener.onError(ErrorType.RETRIEVAL, "Could not check location availability:\n" +
                    e.getMessage());
        return false;
    }
}
项目:dashit    文件:LocationAssistant.java   
private boolean checkLocationAvailability() {
    if (!googleApiClient.isConnected() || !permissionGranted) return false;
    try {
        LocationAvailability la = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        return (la != null && la.isLocationAvailable());
    } catch (SecurityException e) {
        if (!quiet)
            Log.e(getClass().getSimpleName(), "Error while checking location availability:\n " + e.toString());
        if (listener != null)
            listener.onError(ErrorType.RETRIEVAL, "Could not check location availability:\n" +
                    e.getMessage());
        return false;
    }
}
项目:FMTech    文件:fda.java   
public final void handleMessage(Message paramMessage)
{
  switch (paramMessage.what)
  {
  default: 
    return;
  case 0: 
    this.a.a((LocationResult)paramMessage.obj);
    return;
  }
  this.a.a((LocationAvailability)paramMessage.obj);
}
项目:android_OpenLocationCodes    文件:Locator.java   
@Override
public void onConnected(final Bundle bundle) {
    if (! mGoogleApiClient.isConnected()) {
        Log.w("OpenLocationCodes", "GoogleApiClient was disconnected");
        return;
    }
    if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
        // TODO
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull final Status status) {
            if (status.isSuccess()) {
                Log.d("OpenLocationCodes", "LocationServices: SUCCESS");
                final LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(mGoogleApiClient);
                if (locationAvailability != null && locationAvailability.isLocationAvailable()) {
                    onLocationChanged(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
                }
            } else if (status.isCanceled()) {
                Log.d("OpenLocationCodes", "LocationServices: CANCELED");
            } else if (status.isInterrupted()) {
                Log.d("OpenLocationCodes", "LocationServices: INTERRUPTED");
            }
        }
    });
}
项目:Android-BluetoothSPPLibrary-master    文件:RSSPullService.java   
public void insertGyroTOserver(final String dt,final String x, final String y, final String z)
    {
        if(lat!=0 || lng!=0) {
            try {
                LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
                if (locationAvailability.isLocationAvailable()) {
                    // Call Location Services
                    LocationRequest locationRequest = new LocationRequest()
                            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
                    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
                }
//                String queryString = createQueryString(params);
                final String SITE_URL = "http://168.63.175.28/addGyro.php";
                TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                RequestBody formBody = new FormEncodingBuilder()
                        .add("isAdd", "true")
                        .add("imei", telephonyManager.getDeviceId())
                        .add("time",dt)
                        .add("x", x)
                        .add("y", y)
                        .add("z", z)
                        .add("lat",String.valueOf(lat))
                        .add("lng",String.valueOf(lng))
                        .build();
                PostForm p= new PostForm(formBody,SITE_URL);
                final Toast toast = Toast.makeText(getApplicationContext(), "มีการกระแทกเกิดขึ้น", Toast.LENGTH_SHORT);
//                toast.show();
            }
            catch (Exception ex) {
                Log.v("ex", ex.toString());
            }
        }
    }
项目:Android-BluetoothSPPLibrary-master    文件:GoogleLocation.java   
public void Start(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
项目:Android-BluetoothSPPLibrary-master    文件:GoogleLocation.java   
public void Stop(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
项目:drivedata    文件:CaptureActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
项目:drivedata    文件:CaptureActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
项目:LocationAware    文件:LocationAwareService.java   
@Override public void onLocationAvailability(LocationAvailability locationAvailability) {
  Log.i("Debug ", "On Location availability");
}
项目:RxTask    文件:RequestLocationAvailabilityObservable.java   
public ResultCallback(ObservableTaskCallback<LocationAvailability> callback) {
    this.callback = callback;
}
项目:RxTask    文件:RequestLocationAvailabilityObservable.java   
public void onLocationAvailability(LocationAvailability result) {
    super.onLocationAvailability(result);
    callback.onNext(result);
}
项目:RxLocation    文件:MockFusedLocationProvider.java   
@Override
public LocationAvailability getLocationAvailability(GoogleApiClient googleApiClient) {
    throw new UnsupportedOperationException("Stub!");
}
项目:Tower-develop    文件:GoogleMapFragment.java   
@Override
public void onLocationAvailability(LocationAvailability locationAvailability) {
    super.onLocationAvailability(locationAvailability);
}
项目:FMTech    文件:fca.java   
public static LocationAvailability a(Parcel paramParcel)
{
  int i = 1;
  int j = efj.a(paramParcel);
  int k = 0;
  int m = 1000;
  long l = 0L;
  int n = i;
  while (paramParcel.dataPosition() < j)
  {
    int i1 = paramParcel.readInt();
    switch (0xFFFF & i1)
    {
    default: 
      efj.b(paramParcel, i1);
      break;
    case 1: 
      efj.a(paramParcel, i1, 4);
      n = paramParcel.readInt();
      break;
    case 1000: 
      efj.a(paramParcel, i1, 4);
      k = paramParcel.readInt();
      break;
    case 2: 
      efj.a(paramParcel, i1, 4);
      i = paramParcel.readInt();
      break;
    case 3: 
      efj.a(paramParcel, i1, 8);
      l = paramParcel.readLong();
      break;
    case 4: 
      efj.a(paramParcel, i1, 4);
      m = paramParcel.readInt();
    }
  }
  if (paramParcel.dataPosition() != j) {
    throw new bm("Overread allowed size end=" + j, paramParcel);
  }
  return new LocationAvailability(k, m, n, i, l);
}
项目:FMTech    文件:fcz.java   
public final void a(LocationAvailability paramLocationAvailability)
{
  a(1, paramLocationAvailability);
}
项目:FMTech    文件:fwh.java   
public final void a(LocationAvailability paramLocationAvailability)
{
  this.a.a(new fvp(this, paramLocationAvailability));
}
项目:android_packages_apps_GmsCore    文件:GoogleLocationManagerServiceImpl.java   
@Override
public LocationAvailability getLocationAvailabilityWithPackage(String packageName) throws RemoteException {
    Log.d(TAG, "getLocationAvailabilityWithPackage: " + packageName);
    return new LocationAvailability();
}
项目:wearbooksource    文件:WMapHandheldActivity.java   
@Override
public void onConnected(Bundle bundle) {

    Log.d(TAG, "onConnected()..." ) ;
    locationLastKnown = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);

    if ( locationLastKnown == null ) {
        LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient) ;
        if( locationLastKnown == null ){
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, createLocationRequest(), new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    locationLastKnown = location;

                    Log.d(TAG, "LocationServices.FusedLocationApi.requestLocationUpdate)/onLocationChanged()...locationLastKnown=" + locationLastKnown ) ;

                    refreshPositionOnMap();

                }
            });
        }


        boolean locationAvailabilityFlag= false ;

        if ( locationAvailability != null ) {
            locationAvailabilityFlag = locationAvailability.isLocationAvailable() ;
        }

        Log.d(TAG, "onConnected()...locationAvailability=" + locationAvailability  ) ;
    }

    Log.d(TAG, "onConnected()...locationLastKnown=" + locationLastKnown ) ;

    refreshPositionOnMap();

}
项目:FMTech    文件:fea.java   
public abstract void a(LocationAvailability paramLocationAvailability);
项目:FMTech    文件:fcb.java   
public void a(LocationAvailability paramLocationAvailability) {}
项目:FMTech    文件:fcs.java   
public abstract LocationAvailability c(String paramString);
项目:FMTech    文件:fvp.java   
public fvp(fwh paramfwh, LocationAvailability paramLocationAvailability) {}