Alarm not getting stopped

前端 未结 3 1630
清歌不尽
清歌不尽 2021-01-07 08:58

I am trying to stop the alarm and checking it whether it stopped or not, but it always returns true means alarm is working. I tried to stop the alarm based on the answer in

3条回答
  •  一个人的身影
    2021-01-07 09:30

    Here is my code that i am using to cancel the alarm service

    Intent intent = new Intent(this, MyReceiver.class);
             PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
             AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
             alarmManager.cancel(sender);
    

提交回复
热议问题