Open the contacts application by using contact data
You can open the contacts application on a BlackBerry® device and display a contact by using the Invoke.invokeApplication() method, and passing in contact data as a parameter of an AddressBookArguments object.
- Import the required classes and interfaces.
import net.rim.blackberry.api.invoke.AddressBookArguments;
import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.pdap.BlackBerryContact;
import net.rim.blackberry.api.pdap.BlackBerryContactList;
import net.rim.device.api.system.ControlledAccessException;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;
- Invoke PIM.getInstance() to retrieve a PIM instance, and invoke
PIM.openPIMList(int, int) to open the default contact list, passing in as parameters the type of list to open (PIM.CONTACT_LIST) and the access mode with which to open the list (PIM.READ_WRITE, PIM.READ_ONLY, or PIM.WRITE_ONLY).
To open a named contact list, you can instead invoke PIM.openPIMList(int, int, String).
BlackBerryContactList contactList = (BlackBerryContactList)
PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
- Invoke BlackBerryContactList.getByUID(String uid)
to retrieve a contact from the contact list.
BlackBerryContact contact = contactList.getByUID("1XKIOD898");
- Create an instance of the AddressBookArguments class, passing in a Contact object
as a parameter.
AddressBookArguments abArg = new AddressBookArguments("ARG_VIEW", contact);
- Invoke Invoke.invokeApplication(APP_TYPE_ADDRESSBOOK, AddressBookArguments) and use the AddressBookArguments object for the contact.
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, abArg);
- Check for PIMException, and check for ControlledAccessException if your application does not have permission to access
the application that it invokes.
Was this information helpful? Send us your comments.