Reputation: 382616
How do i add the functionality to import a contact number from address book/contact list and add it into an array?
Edit
If you have seen the advanced call manager app, it allows you to choose a contact from contact list and add to blacklist. I want to do same thing choose a contact from contact list and add to internal array.
Details:
Nokia N70
CLDC 1.1
MIDP 2.0
Upvotes: 0
Views: 1889
Reputation: 11
try {
verifyPIMSupport();
PIM pimInst = PIM.getInstance();
contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
enumContacts = contList.items();
mainList = new List(":.:PHONE BOOK:.:", List.IMPLICIT);
addCommand = new Command("ADD CONTACTS", Command.OK, 0);
listCommand = new Command("LIST CONTACTS", Command.OK, 0);
exitCommand = new Command("EXIT", Command.EXIT, 0);
deleteCommand = new Command("DELETE ALL", Command.OK, 0);
while (enumContacts.hasMoreElements()) {
Contact tCont = (Contact) enumContacts.nextElement();
String[] name_struct = tCont.getStringArray(Contact.NAME, 0);
String firstname = name_struct[Contact.NAME_GIVEN];
String lastname = name_struct[Contact.NAME_FAMILY];
//String email = tCont.getString(Contact.EMAIL, 0);
// String number = tCont.getString(Contact.TEL, 0);
//String org = tCont.getString(Contact.ORG, 0);
String person = "First Name:" + firstname+ "\n" + "Last Name:"
+ lastname ;
//String person = "First Name:" + firstname + "\n" + "Last Name:"
//+ lastname + "\n" + "N0:" + number + "\n" + "Email:" + email + "\n" + "Org:" + org;
mainList.setFitPolicy(1);
mainList.append(person, null);
}
mainList.addCommand(addCommand);
mainList.addCommand(listCommand);
mainList.addCommand(exitCommand);
mainList.addCommand(deleteCommand);
mainList.setCommandListener(this);
display = Display.getDisplay(this);
Upvotes: 1
Reputation: 23
there is 3 options to do so :
adding text field component with this attributes
TextField num = new TextField("num", "", 20, TextField.PHONENUMBER);
now a command called add from contact is added to this text field and when chosen the default contact list will open and allow you to choose a number that will be written in your text field
Upvotes: 1
Reputation: 395
The specifications for the PIM API can be downloaded from the link provided by ruibm. Final release -> download page -> PIM Optional Package Specification. I'm not sure what more you could want other than a direct example....
Upvotes: 1
Reputation: 11284
You need to check if the device supports JSR-75 to get PIM data access. Have a look at this link: http://jcp.org/en/jsr/detail?id=75
Upvotes: 4