Example #1
0
 private void requestLocationUpdates() {
   LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
   lm.removeUpdates(this);
   List<String> providers = SamplingLibrary.getEnabledLocationProviders(context);
   if (providers != null) {
     for (String provider : providers) {
       lm.requestLocationUpdates(provider, CaratApplication.FRESHNESS_TIMEOUT, 0, this);
       // Log.v(TAG, "Location updates requested for " + provider);
     }
   }
 }
Example #2
0
  @Override
  public void onReceive(Context context, Intent intent) {
    if (this.context == null) {
      this.context = context;
      requestLocationUpdates();
    }

    // Update last known location...
    if (lastKnownLocation == null)
      lastKnownLocation = SamplingLibrary.getLastKnownLocation(context);

    // Log.i(TAG, "Carat received Intent: "+intent.getAction());

    Intent service = new Intent(context, SamplerService.class);
    service.putExtra("OriginalAction", intent.getAction());
    service.fillIn(intent, 0);
    service.putExtra("lastBatteryLevel", lastBatteryLevel);
    service.putExtra("distance", distance);
    startWakefulService(context, service);
  }