Esempio n. 1
0
 private void showWarningIfGPSOff() {
   if (GeoUtils.isGPSDisabled(myActivity)) {
     Log.d(LOG_TAG, "GPS disabled!");
     warningText.setVisibility(View.VISIBLE);
     warningText.setText("Enable GPS");
   } else {
     Log.d(LOG_TAG, "GPS enabled!");
     warningText.setVisibility(View.GONE);
   }
 }
Esempio n. 2
0
 private void analyseInitLocation(Location l) {
   if (l != null) {
     myCurrentAccuracy = l.getAccuracy();
     long passedTime = System.currentTimeMillis() - l.getTime();
     Log.d(
         LOG_TAG,
         "Passed time since last location event=" + (passedTime / 1000f / 10f) + " minutes");
     if (passedTime <= MAX_TIME_SINCE_LAST_UPDATE_IN_MS) onLocationChanged(l);
   } else {
     GeoUtils.enableLocationProvidersIfNeeded(myActivity);
   }
 }
Esempio n. 3
0
 private void analyseInitLocation(Location l) {
   if (l != null) {
     myCurrentAccuracy = l.getAccuracy();
     long passedTime = System.currentTimeMillis() - l.getTime();
     Log.i(LOG_TAG, "Last known pos accuracy=" + myCurrentAccuracy);
     Log.i(LOG_TAG, "Last known pos age=" + (passedTime / 1000f / 10f) + " minutes");
     if (passedTime <= MAX_TIME_SINCE_LAST_UPDATE_IN_MS) {
       onLocationChanged(l);
     } else {
       Log.i(
           LOG_TAG,
           "Last known pos age was to old to use it "
               + "as a current position, will now wait "
               + "for position signal");
       myCurrentAccuracy = 1000; // 1000m
     }
   } else {
     GeoUtils.enableLocationProvidersIfNeeded(myActivity);
   }
 }
Esempio n. 4
0
 /**
  * @param context
  * @param minAccuracy should be >= 25m
  * @param maxPosUpdateCount The max number of update events before the position should be accurate
  *     enough (something around 6)
  */
 public ActionWaitForAccuracy(Activity context, float minAccuracy, int maxPosUpdateCount) {
   myActivity = context;
   myMinAccuracy = minAccuracy;
   myMaxPosUpdateCount = maxPosUpdateCount;
   analyseInitLocation(GeoUtils.getCurrentLocation(context));
 }