title: Android set repeating task at same time everyday using AlarmManager
body: <p>Have to schedule an event at 8 pm (the clock shows 8 pm) everyday irrespective of the user moving across different timezones. Set repeating with interval of one day will not deliver it at the correct time. How to approach this?</p>
  
  <p><a href="https://stackoverflow.com/questions/24196890/android-schedule-task-to-execute-at-specific-time-daily">This</a> is the closest I've got so far. </p>
  
  <p>Code snippet:</p>
  
  <pre><code>private AlarmManager alarmMgr;
  private PendingIntent alarmIntent;
  ...
  alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent intent = new Intent(context, AlarmReceiver.class);
  alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
  
  // Set the alarm to start at 20:00 PM
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(System.currentTimeMillis());
  calendar.set(Calendar.HOUR_OF_DAY, 20);
  calendar.set(Calendar.MINUTE, 0);
  
  // setRepeating() lets you specify a precise custom interval--in this case,
  // 1 day
  alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
          AlarmManager.INTERVAL_DAY, alarmIntent);
  </code></pre>