How do I get the Alarm Class to Trigger Properly Everytime?

13 Views Asked by At

I have a method in my Broadcast Reciever to start a timer of 1 sec after a certain condition is met, the issue arises that, when the condition is met successfully once, the method gets triggered successfully, and the timer is set, however when the condition is met for the second time, the method is not called, and the timer is not working

This is my method

 private void setTimer(int durationSeconds, String message) {
        Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER)
                .putExtra(AlarmClock.EXTRA_LENGTH, durationSeconds)
                .putExtra(AlarmClock.EXTRA_RINGTONE, getRingtoneUri())
                .putExtra(AlarmClock.EXTRA_VIBRATE, true)
                .putExtra(AlarmClock.EXTRA_MESSAGE, message)
                .putExtra(AlarmClock.EXTRA_SKIP_UI, true)
                .addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
        try {
            // Try setting the timer
            startActivity(intent);
        } 

I have experimented with various different intent flags, but cannot get them to work

0

There are 0 best solutions below