title: setrepeating alarmmanager with changing values
body: <p>Can we use setrepeating in alarmmanager with changing values? For instance,</p>
  
  <pre><code>alarm.setRepeating(AlarmManager.RTC_WAKEUP, 0,
                      AlarmManager.INTERVAL_DAY*14, pi);
  </code></pre>
  
  <p>sets the interval to be 14 days. But if my phone restarts the alarm resets from start. I can write the value for the next alarm to file on SD card, but i am confused that how to call that value in alarm manager? </p>
  
  <p>---------------------------------UPDATE 2-----------------------</p>
  
  <p>The updated logic is:
  In broadcast receiver: </p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
              Intent i = new Intent(context, MainActivity.class);  
              i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(i);
      }
  </code></pre>
  
  <p>In Main Activity:</p>
  
  <pre><code>SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
  long nextTime = prefs.getLong("timerval", 0);
  Intent ishintent = new Intent(this, MyService.class);
  PendingIntent pi = PendingIntent.getService(this, 0, ishintent, PendingIntent.FLAG_UPDATE_CURRENT);
  AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
  alarm.setRepeating(AlarmManager.RTC_WAKEUP, nextTime,
                          AlarmManager.INTERVAL_DAY*14, pi);
  </code></pre>
  
  <p>While, MyService is a service that start my actual activity, and in that activity, when user clicks "Submit" button, after saving the data, the next timer fire time is calculated and saved like this:</p>
  
  <pre><code>SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  Editor editor = prefs.edit();
  Long nextint = System.currentTimeMillis() + 60000;
  editor.putLong("timerval", nextint );
  editor.commit();
  </code></pre>
  
  <p>But the issue is that on phone restart app still pop ups. Any ideas?</p>