gpt4 book ai didi

android - 删除报警 :Android

转载 作者:行者123 更新时间:2023-11-29 19:10:48 25 4
gpt4 key购买 nike

这是我的 addAlarm() 方法:

Intent intent = new Intent(this, ALReciver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 10 , intent, PendingIntent.FLAG_UPDATE_CURRENT| Intent.FILL_IN_DATA);

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),pendingIntent );

此代码工作正常,但我想使用以下代码删除此警报:

 Intent intent = new Intent(this, ALReciver.class);
PendingIntent sender = PendingIntent.getBroadcast(this,10, intent,PendingIntent.FLAG_CANCEL_CURRENT);

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

alarmManager.cancel(sender);

此代码无效..我不明白我做错了什么?

最佳答案

替换:

PendingIntent sender = PendingIntent.getBroadcast(this,10, intent,PendingIntent.FLAG_CANCEL_CURRENT);

PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 10 , intent, PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);

关于android - 删除报警 :Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45412342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com