title: Do I need to Use an AlarmManager and WakeLock to periodically use a LocationClient?
body: <p>Posts from over a year ago suggest that it is necessary to use a WakeLock to reserve CPU to gather location information (CommonsWare in particular here <a href="https://stackoverflow.com/questions/9869153/android-periodic-gps-location-updates-with-alarmmanager-inside-a-service">Android Periodic GPS location updates with AlarmManager inside a Service</a>). However I do not understand why I cannot simply call a Service every 28 minutes, connect the LocationClient, set a timer to wait 2 minutes, then get the most recent location, disconnect the client, and then stop the service. </p>
  
  <p>Because Commonsware and the user who forked his example here (<a href="https://github.com/alexbirkett/cwac-locpoll/blob/master/src/com/commonsware/cwac/locpoll/LocationPollerService.java" rel="nofollow noreferrer">https://github.com/alexbirkett/cwac-locpoll/blob/master/src/com/commonsware/cwac/locpoll/LocationPollerService.java</a>) use a LocationListener, and not a LocationClient, I was wondering whether his answer still aplies. </p>
  
  <p>Thanks for your time!</p>
  
  <p><strong>EDIT:</strong> Is it this simple, where an AlarmManager calls a Service every 28 minutes > the Service acquires a WakeLock and a timer elapses for two minutes as the LocationClient is connect > once two minutes has elapsed, I can kill the service and release the WakeLock?</p>
  
  <p>It would look something like this: </p>
  
  <pre><code>    PowerManager pm = (PowerManager) getBaseContext().getSystemService(Context.POWER_SERVICE);
      PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "");
      wl.acquire();
  
      Timer theTimer = new Timer();
      theTimer.schedule(new TimerTask() {
  
          @Override
          public void run() {
              if(checkIfGooglePlay()) {
                  getPostLocation();
                  w1.release();
                  stopSelf(); 
              }
          }
      }, TWO_MINUTES);
  
      return Service.START_NOT_STICKY;
  </code></pre>