Alarm manager triggered immediately

后端 未结 2 1612
死守一世寂寞
死守一世寂寞 2021-02-04 05:26

Hi I am currently working with AlarmManager. I have written a code given below. As per code the AlarmManager should be triggered after 10 Sec, but here in my code the alarm mana

2条回答
  •  半阙折子戏
    2021-02-04 06:03

    You are using an alarm type of ELAPSED_REALTIME_WAKEUP. That means that the second parameter to set() must be the number of milliseconds from now, where now is expressed as SystemClock.elapsedRealtime().

    If your goal is to have this occur 10000 milliseconds from the time you make the set() call, that set() call should be:

    alarmManager.set(alarmType, SystemClock.elapsedRealtime()+timeOrLengthofWait, alarmIntent);
    

提交回复
热议问题