Troubleshooting guide
179
11: Using PIM applications
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_VALUE + 9:
• STATUS_NOT_STARTED: 1
• STATUS_IN_PROGRESS: 2
• STATUS_COMPLETED: 3
• STATUS_WAITING: 4
task.addInt(ToDo.EXTENDED_FIELD_MIN_VALUE + 9, ToDo.ATTR_NONE, 2);