2

This is the code:

public void startAlarm(Context context) {
    Intent intent = new Intent(context, SyncService.class);
    PendingIntent sender = PendingIntent.getService(context, 0, intent, 0);

    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                10 min, 20 min, sender);

}

This is my method where I start my alarm... I use it in my main activity in onCreate method... What if I change something in settings, and I want to change a time of Repeating? How to do that? I should kill that one and start new one?

Juan José Melero Gómez
  • 2,742
  • 2
  • 19
  • 36
Jim
  • 8,874
  • 16
  • 68
  • 125

1 Answers1

4

If you read the docs you will notice the following:

If there is already an alarm scheduled for the same IntentSender, it will first be cancelled.

Flow
  • 23,572
  • 15
  • 99
  • 156
Rob
  • 56
  • 3