title: get current device location after specific interval
body: <p>I want to capture current location (latitude and longitude) of android device after specific interval (say 30 mins).. My class (or service ?? not sure what to use ) will start listening to <code>LocationManagerListener</code> when device booting completed. What is the best way of implementing this? how we can make use of <code>locationChanged()</code> method in this scenario?   </p>
  
  <p>This is what i think it can go:</p>
  
  <p>Listen for boot completed event and set alarm service:</p>
  
  <pre><code>public class OnBootReceiver extends BroadcastReceiver {
    private static final int PERIOD=1800000; // 30 minutes
  
    @Override
    public void onReceive(Context context, Intent intent) {
  
      AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
      Intent i=new Intent(context, OnAlarmReceiver.class);
      PendingIntent pi=PendingIntent.getBroadcast(context, 0,
                                                i, 0);
  
      mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                        SystemClock.elapsedRealtime()+60000,
                        PERIOD,
                        pi);
    }
  }
  </code></pre>
  
  <p>Listen for alarm service and initiate the location capture class or service:</p>
  
  <pre><code> public class OnAlarmReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {    
        WakefulIntentService.acquireStaticLock(context);  
        context.startService(new Intent(context, locationCapture.class)); 
        or 
        new locationCapture().classmethod();
      }
      }
  </code></pre>
  
  <p>I am not sure how <code>locationCapture</code> class should be implemented. Should it be normal Java class or Service class?</p>
  
  <p>Any help will be appreciated.</p>