/** flush cache */ public void flushCache() { Iterator<Long> iterator = locationCache.keySet().iterator(); while (iterator.hasNext()) { Long timeMillis = iterator.next(); Location location = locationCache.get(timeMillis); if (archiver.add(location, timeMillis)) { Helper.Logger.i( String.format( "Location(%f, %f) has been saved into database.", location.getLatitude(), location.getLongitude())); } } locationCache.clear(); }
@Override public void onStatusChanged(String provider, int status, Bundle extras) { switch (status) { case LocationProvider.AVAILABLE: // binder.startRecord(); Helper.Logger.i("Location provider is available."); break; case LocationProvider.OUT_OF_SERVICE: Helper.Logger.w("Location provider is out of service."); // binder.stopRecord(); break; case LocationProvider.TEMPORARILY_UNAVAILABLE: Helper.Logger.w("Location provider is temporarily unavailable."); // binder.stopRecord(); break; } }
@Override public void onProviderEnabled(String s) { Helper.Logger.i("Location provider is enabled."); }