40
BlackBerry Device Applications Integration Guide
Use tasks
Task
Steps
Open a task list.
>
Invoke
PIM.openPIMList()
and provide as parameters the type of list to open
(
PIM.TODO_LIST
) and the access mode with which to open the list (READ_WRITE, READ_ONLY,
or WRITE_ONLY).
ToDoList todoList = null;
try {
todoList = (ToDoList)PIM.getInstance().openPIMList(PIM.TODO_LIST,
PIM.READ_WRITE);
} catch (PimException e) {
//an error occurred
return;
}
Create a task.
>
Invoke
createToDo()
on a task list.
ToDo task = todoList.createToDo();
Add task information.
1.
Before you set or retrieve a field, verify that the item supports the field by invoking
isSupportedField(int)
.
2. To retrieve the field data type, invoke
PIMList.getFieldDataType(int)
.
3. To set the field data, invoke one of the following methods:
•
addString()
•
addDate()
•
addInt()
•
addBoolean()
•
addBinary()
if (todoList.isSupportedField(ToDo.SUMMARY)) {
task.addString(ToDo.SUMMARY, ToDo.ATTR_NONE, "Create project plan");
}
if (todoList.isSupportedField(ToDo.DUE)) {
Date date = new Date();
task.addDate(ToDo.DUE, ToDo.ATTR_NONE, (date + 17280000));
}
if (todoList.isSupportedField(ToDo.NOTE)) {
task.addString(ToDo.NOTE, ToDo.ATTR_NONE, "Required for meeting");
}
if (todoList.isSupportedField(ToDo.PRIORITY)) {
task.addInt(Todo.PRIORITY, ToDo.ATTR_NONE, 2);
}
Set the status of a task.
>
Use the PIM extended field ToDo.EXTENDED_FIELD_MIN 9:
•
STATUS_NOT_STARTED: 1
•
STATUS_IN_PROGRESS: 2
•
STATUS_COMPLETED: 3
•
STATUS_WAITING: 4
task.addInt(BlackBerryToDo.STATUS, ToDo.ATTR_NONE,
BlackBerryToDo.STATUS_COMPLETED);
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Page 4: ......
Page 7: ......
Page 10: ...10 BlackBerry Device Applications Integration Guide...
Page 12: ...12 BlackBerry Device Applications Integration Guide...
Page 50: ...50 BlackBerry Device Applications Integration Guide...
Page 56: ...56 BlackBerry Device Applications Integration Guide...
Page 65: ......
Page 66: ...2008 Research In Motion Limited Published in Canada...