BlackBerry Device Applications Integration Guide
Use tasks
Task
Open a task list.
Create a task.
Add task information.
Set the status of a task.
40
Steps
PIM.openPIMList()
>
Invoke
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;
}
createToDo()
>
Invoke
on a task list.
ToDo task = todoList.createToDo();
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
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);
}
>
Use the PIM extended field ToDo.EXTENDED_FIELD_MIN_VALUE + 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);
and provide as parameters the type of list to open
.
PIMList.getFieldDataType(int)
.