Question

I need to put several reminders in the BB calendar. The idea is several hours, or days before a promo expires, the alarm will remind it for you.

Here's my code so far:

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){

}

Every time i run it, an "IllegalArgumentException" is always thrown. I'm not really sure what goes wrong here...

Was it helpful?

Solution

I think that this is wrong:

bbEvent.addDate(BlackBerryEvent.ALARM,0,time)

and that you should use:

bbEvent.addInt(BlackBerryEvent.ALARM,0,time2) 

take care that "time2" is long !

And you can add two other dates for example:

bbEvent.addDate(bbEvent.START, PIMItem.ATTR_NONE, 
                System.currentTimeMillis()+120000);

bbEvent.addDate(bbEvent.END, PIMItem.ATTR_NONE, 
                System.currentTimeMillis()+360000);

Try it and tell me your experience in it.

OTHER TIPS

BlackBerryEvent ev = (BlackBerryEvent) _event;
ev.addInt(BlackBerryEvent.ALARM, BlackBerryEvent.ATTR_NONE,remMinInt*60);

_event.commit();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top