If I type a phone number into the phone application on my Blackberry (5.0.0) I can hit the menu button, and one of the options is "Add to contacts" which will bring up the add contact screen, with the phone number already populated. I would like to do the same thing in my app - bring up the 'add to contacts' screen and pre-fill it with a particular phone number. Is this possible on the BlackBerry 5.0 OS?
A:
While browsing for more information on BlackBerry contacts, I came across this support forum question, which answers my question indirectly. Posted here for anyone else in a similar situation: http://supportforums.blackberry.com/t5/Java-Development/Problem-adding-contact-to-phone/m-p/341728/highlight/true#M62692
try
{
ContactList contacts = null;
try {
contacts = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// An error occurred
return;
}
Contact contact = contacts.createContact();
String[] name = new String[ contacts.stringArraySize( Contact.NAME ) ];
name[Contact.NAME_GIVEN] = "Kate";
name[Contact.NAME_FAMILY] = "Turner";
contact.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
AddressBookArguments entry = new AddressBookArguments(AddressBookArguments.ARG_NEW, contact);
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, entry);
}
catch (Throwable t)
{
}
Michael Donohue
2010-07-09 17:48:28