Ejemplo n.º 1
0
  private void checkGPS(Context context, final boolean forceClose) {
    GPSTracker gpsTracker = new GPSTracker(context);
    if (gpsTracker.canGetLocation()) {
      boolean enable = SharedValues.getEnableLocation(context);
      double offRange = SharedValues.getOffRange(context);
      double lat = SharedValues.getLat(context);
      double lng = SharedValues.getLng(context);

      Log.d(
          "locationn",
          "setting is: " + enable + " offRange: " + offRange + " lat: " + lat + " lng: " + lng);
      if (enable && offRange != 0 && lat != 0 && lng != 0) {
        double distance =
            calculateDistance(lat, lng, gpsTracker.getLatitude(), gpsTracker.getLongitude());
        Log.d(
            "locationn",
            "getting lat: " + gpsTracker.getLatitude() + " lng: " + gpsTracker.getLongitude());
        Log.d("locationn", "getting distance: " + distance);

        if (distance >= offRange) {
          Log.d("locationn", "distance >= offRange");
          SwitchCloseTask task = new SwitchCloseTask(context);
          task.execute();
        }
      }
    }
  }