I'm building an app to create events in the device Calendar, but when I have created them, all are set default without sound. I need to set the sound ON, when the user wants it. How can I set the sound on the alarm in my created events?
1 Answers
Some guy from the nokia developer forum, solve my question.
He tells me that
You cannot access the Alarm from your Java app, but you can use the PIM API to create a Calendar event and add it (or better say import it) to the native Calendar app. The native Calendar application on Series 40 and Asha software platform devices, comes with a Reminder option that specifies how long before the event the user should get a notification sound about the event. This field can get several values (e.g. none, at start time, 5 minutes before, 10 minutes before etc). You can therefore specify a calendar event for a certain date and time and define its reminder attribute to "at start time". The calendar app doesn't allow you to specify the sound used for the reminder but rather uses the reminder tone defined in the device's sound settings under Settings > Sounds and vibra > Reminder tone (on asha software platform devices). The reminder uses the device's volume level. You cannot override neither the selected tone nor the volume level. So if the device is muted, when the reminder is activated there will be no generated sound, but otherwise the reminder should be heard in the tone and volume level set in the device's settings. This is how you add an event with a reminder value set to "at start time" (tested on Nokia asha software platform and Nokia 501) Code:
pim = PIM.getInstance();
try {
EventList eventList = (EventList) pim.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
Event event = eventList.createEvent();
// get the current date
Date date = new Date();
// create a reminder starting 1 minute from now
event.addDate(Event.START, Event.ATTR_NONE, date.getTime() + 60000);
// and ending in 2 minutes from now
event.addDate(Event.END, Event.ATTR_NONE, date.getTime() + 120000);
/*
* set the reminder value. 1 = at start time
* 300 = 5 minutes before
* 600 = 10 minutes before
* 900 = 15 minutes before
*/
event.addInt(Event.ALARM, 0, 1);
// import the event to calendar
Event imported = eventList.importEvent(event);
imported.commit();
eventList.close();
} catch (PIMException ex) {
System.out.println(ex.getMessage());
}

- 4,438
- 4
- 28
- 46