问题取消报警经理挂起的意图意图、挂起、经理、问题

2023-09-04 23:57:03 作者:软妹蘑菇酱

我的应用程序,它提醒人们,以使他们的任务。所以,有一个悬而未决的意图,现在用户可以删除alram当他想。 IB此code有多个用户报警只是一个悬而未决的意图,所以我很困惑的取消特定的报警,其中额外的。剩余的警报不应该被取消。我对这个问题毫无头绪。希望我是清楚的。谢谢

 意向意图=新的意图(这一点,AlarmNotifyReceiver.class);
intent.putExtra(Name_pill,丸);
发件人= PendingIntent.getBroadcast(这一点,
DatabaseConstants.NOTIFICATION_ID + 1,意向,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager AM =(AlarmManager)getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),发送方);
updateTheFlag(pillName [(pillName.length-1)]);
 

解决方案

根据Android的文档,以阻止报警,您应该创建一个意图的相同的数据,但是的没有的一定是相同的演员:

  

公共无效取消(PendingIntent操作)

     

删除任何警报与匹配的意图。任何报警,任何类型的,其意图匹配这个>一(通过的 filterEquals定义(意图)的),将被取消。

filterEquals(意向)

  

公共布​​尔filterEquals(意向等)

     

确定是否两个目的都是相同的意图分辨率(滤波)的目的。 >即,如果它们的作用,数据,类型,类别和类别是相同的。 这不比较列入意图任何额外的数据。

I have app which reminds people to so their task. So there is one pending intent,now the user can delete the alram when he wants to. Ib this code there is just one pending intent for multiple user alarms so I am confused on cancelling that particular alarm where extras is "pill". The remaining alarms should not be cancelled .I have no clue on this problem. Hope i am clear. Thanks

Intent intent = new Intent(this, AlarmNotifyReceiver.class);
intent.putExtra("Name_pill", "pill");
sender = PendingIntent.getBroadcast(this,
DatabaseConstants.NOTIFICATION_ID + 1, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(), sender);
updateTheFlag(pillName[(pillName.length-1)]);
项目经理常见问题解决思路1 4个.pdf文档类 项目管理文档类资源 CSDN下载

解决方案

According to the Android documentation, in order to stop an alarm, you should create an Intent with the same data, but not necessarily the same extras:

public void cancel (PendingIntent operation)

Remove any alarms with a matching Intent. Any alarm, of any type, whose Intent matches this > one (as defined by filterEquals(Intent)), will be canceled.

filterEquals(Intent)

public boolean filterEquals (Intent other)

Determine if two intents are the same for the purposes of intent resolution (filtering). > That is, if their action, data, type, class, and categories are the same. This does not compare any extra data included in the intents.