问题取消报警经理挂起的意图 [英] problem with cancel the alarm manager pending intent

查看:132
本文介绍了问题取消报警经理挂起的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序,它提醒人们,以使他们的任务。所以,有一个悬而未决的意图,现在用户可以删除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)]);

解决方案

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.

这篇关于问题取消报警经理挂起的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆