我需要在BB日历中添加几个提醒。 这个想法是宣传片到期前几个小时或几天,闹钟会为你提醒。
到目前为止,这是我的代码:
long ONE_HOUR = 3600;
long ONE_DAY = 24 * 3600;
try {
EventList eventList = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
BlackBerryEvent bbEvent = (BlackBerryEvent) eventList.createEvent();
FavoritePromo promo;
if (eventList.isSupportedField(BlackBerryEvent.ALARM)){
for (int x = 0; x < promos.size(); x++){
promo = (FavoritePromo) promos.elementAt(x);
time = (StringUtil.strToDate(promo.getExpireDate())).getTime() - value;
bbEvent.addString(BlackBerryEvent.SUMMARY, BlackBerryEvent.ATTR_NONE, promo.getTitle());
bbEvent.addDate(BlackBerryEvent.ALARM,0,time);
bbEvent.commit();
}
}
}
catch (PIMException e){
}
每次运行它时,总会抛出“IllegalArgumentException”。我不确定这里出了什么问题......
答案 0 :(得分:1)
BlackBerryEvent ev =(BlackBerryEvent)_event;
ev.addInt(BlackBerryEvent.ALARM,
BlackBerryEvent.ATTR_NONE,remMinInt * 60);
_event.commit();
答案 1 :(得分:0)
我认为这是错误的:
bbEvent.addDate(BlackBerryEvent.ALARM,0,time)
你应该使用:
bbEvent.addInt(BlackBerryEvent.ALARM,0,time2)
注意“time2”很长!
您可以添加另外两个日期,例如:
bbEvent.addDate(bbEvent.START, PIMItem.ATTR_NONE,
System.currentTimeMillis()+120000);
bbEvent.addDate(bbEvent.END, PIMItem.ATTR_NONE,
System.currentTimeMillis()+360000);
尝试并告诉我你的体验。