title: Code set to run during a timer is being triggered intermittently
body: <p>I have a countdown timer that runs when a user presses a button, at the conclusion of the timer, the location of the device is sent to another device for which the user enters a phone number for.  Here is my timer code:: </p>
  
  <pre><code>private void initTimer() {
  
      if(timer==null)
      {
  
          long totalTime= (PersistData.getIntData(con, AppConstant.selectedMinute)*60*1000)+(PersistData.getIntData(con, AppConstant.selectedseconds)*1000);
          timer=new CountDownTimer(totalTime, 1000) {
  
              public void onTick(long millisUntilFinished) {
  
  
                  timerView.setText(getFormatterTimerText(millisUntilFinished));
  
                  if(millisUntilFinished&lt;60*1000)
                  {
  
                      continueFlashAndAudio();
  
                       /*
                  refresh GPS Location again
                   */
  
                      updateGPSLocation (millisUntilFinished);
                  }
  
  
  
              }
  
              public void onFinish() {
  
                  showFinishView();
              }
          };
  
      }
  }
  </code></pre>
  
  <p>When the timer runs, it is supposed to run the "updategpslocation" function:</p>
  
  <pre><code>private void updateGPSLocation(long millisUntilFinished) {
  
      Log.e("current time remaining", " time: "+millisUntilFinished/1000);
  
  
      if(millisUntilFinished/1000==30)
  
      {
  
          Log.e("30 seconds remaining", "get locaiton");
  
          getLocation();
      }
  
      if(millisUntilFinished/1000==10)
  
      {
  
          Log.e("10 seconds remaining", "get locaiton");
  
          getLocation();
      }
  }
  </code></pre>
  
  <p>The issue I am having is that about half the time, the location will not be updated and it will send a location that was previously fetched to the other phone.  </p>
  
  <p>Here is my code to get the location: </p>
  
  <pre><code>private void getLocation()
  {
  
      GPSTracker tracker=new GPSTracker(con);
      if(tracker.canGetLocation())
      {
          Location lastLocation=tracker.getLocation();
  
  
  
  
  
          PersistObject.apply(con,AppConstant.LOCATION,lastLocation);
          Log.e("Location is refreshed", "5 seconds remaining");
  
  
      }
  }
  </code></pre>
  
  <p>I am extremely confused as to why this is happening, I have spent hours on this and have hired a couple freelancers to help and nothing they have done has been able to remedy the issue.  Half the time the code will work fine and it will send the new location of the device, and half the time it will send the location that the device returned previously.  I move the phone around to test new spots and I am running this on three different phones and it happens on all of them intermittently.  Any ideas would be GREATLY appreciated.  </p>