views:

379

answers:

2

I want to acces alarm. in my application i have successfully accessed calender and have set the appointment but how i can access alarm. please help me. following is my code

public class Alarm 
{
    private Event event;
    public void myAlarm()
    {
        try
        {
            EventList eventList = (EventList)PIM.getInstance().
            openPIMList(PIM.EVENT_LIST, PIM.WRITE_ONLY);
            event = eventList.createEvent();
            event.addString(event.SUMMARY, PIMItem.ATTR_NONE, "My alarm");
            event.addString(event.LOCATION, PIMItem.ATTR_NONE, "My Location");
            event.addDate(event.END, PIMItem.ATTR_NONE, 
                System.currentTimeMillis()+360000);
            event.addDate(event.START, PIMItem.ATTR_NONE, 
                System.currentTimeMillis()+120000);
            event.commit();
        }//end of try block
        catch(Exception e){}    
    }//end of method myAlarm    
}//end of main class Alarm
A: 

add this code

if (event.isSupportedField(Event.ALARM)) {
   if (event.countValues(Event.ALARM) > 0) {
      event.removeValue(Event.ALARM,0);
      event.setInt(Event.ALARM, 0, Event.ATTR_NONE, 396000);
}
}

For more information read this doc.

Vivart
can you please tell if i want to set alsrm for specific date how can i do that?
alarm date will be depend on event start date suppose you are giving event.setInt(Event.ALARM, 0, Event.ATTR_NONE, 1200); like this, alarm will trigger before 20 min. of start date of event.
Vivart
A: 
Alex