本文介绍了无法取消PendingIntents - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经设定的报警系统,与在那里是信息的服务器同步。
I have programmed an alarm system that synchronizes with the server where are the information.
有时候,在服务器上更新某些告警被删除。现在,人们都从数据库中删除db4o的,但我无法取消已编程pendingIntents。
Sometimes, in the updates on the server some alarms are deleted. Now, it is well removed from the database db4o but I can't cancel pendingIntents already programmed.
现在,我已经下code:
Now, I've the following code:
PendingIntent pendingIntent;
public class xxx{
public void updateObjects(){
alarmManager.cancel(pendingIntent);//delete all alarms
(...)
for(...){
//Update each object ofdb4o with the new object value's.
(...)
doIntents(context,mil,obj);
}
(...)
}
public void doIntents(Context context, long mil, ClassObjects obj){
(...)
pendingIntent = PendingIntent.getBroadcast(context, obj.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
(...)
}
}
任何人可以帮助我取消这些pendingintents我不需要了吗?
Can anybody help me to cancel those pendingintents I don't need already?
感谢您!
推荐答案
有关取消PendingIntent你必须通过同样的 ID
您已经通过了设定的时间。
for cancel PendingIntent you have to pass same ID
that you passed for set time.
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, obj.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
这篇关于无法取消PendingIntents - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!