BlackBerry: ¿cómo crear un evento de alarma?
java-me events (2)
EventList evList = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST,
PIM.READ_WRITE);
BlackBerryEvent ev = (BlackBerryEvent) evList.createEvent();
if (evList.isSupportedField(BlackBerryEvent.ALARM)) {
ev.addInt(BlackBerryEvent.ALARM, BlackBerryEvent.ATTR_NONE, 180); //3 min = 180
//if this field has a value of 180, then the alarm first occurs 180 seconds before the
date/time value specified by Event.START
}
Quiero acceder a la alarma en mi aplicación, he accedido exitosamente al calendario y he programado la cita pero cómo puedo acceder a la alarma. por favor, ayúdame. siguiente es mi código
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
if(field == save)
{
try
{
events = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST,PIM.READ_WRITE );
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++++++++++++++++++"+e);
return;
}
Event event = events.createEvent();
if( events.isSupportedField( Event.SUMMARY ) )
event.addString( Event.SUMMARY, PIMItem.ATTR_NONE, "Meeting with John" );
if( events.isSupportedField( Event.LOCATION ) )
event.addString( Event.LOCATION, PIMItem.ATTR_NONE, "Amritsar" );
if( events.isSupportedField( Event.START ) )
event.addDate( Event.START, PIMItem.ATTR_NONE, aDate.getDate()+60000);
System.out.println("System.currentTimeMillis()+60000 : "+System.currentTimeMillis()+60000);
if( events.isSupportedField( Event.END ) )
event.addDate( Event.END, PIMItem.ATTR_NONE, aDate.getDate()+120000);
System.out.println("System.currentTimeMillis()+120000 : "+System.currentTimeMillis());
if( events.isSupportedField( Event.ALARM ) )
{
event.addInt( Event.ALARM, PIMItem.ATTR_NONE, 900);
}
if( events.isSupportedField( Event.NOTE ) )
event.addString( Event.NOTE, PIMItem.ATTR_NONE,"I phoned on Monday to book this meeting" );
try
{
if( events.maxCategories() != 0 && events.isCategory( "Work" ) )
event.addToCategory( "Work" );
}
catch (PIMException e1)
{
e1.printStackTrace();
}
try
{
event.commit();
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++++++++++++++++++"+e);
}
try
{
events.close();
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++----------------"+e);
}
}