Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 18
Registered: ‎10-23-2012
My Device: 9500
My Carrier: Airtel

Button field should Work as brawse Button for contact list.

[ Edited ]

How can I get contact list or phonebook list on click  on a  button field using the blackberry api? i want to import no/ contact Detail from Number list to An Edit Field..

 

Button field should Work as brawse Button for contact list.

Highlighted
Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Button field should Work as brawse Button for contact list.

welcome to the support forums.

you can use
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/blackberry/api/pdap/BlackBerryContactList...
to select a contact from the addressbook.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 18
Registered: ‎10-23-2012
My Device: 9500
My Carrier: Airtel

Re: Button field should Work as brawse Button for contact list.

thanks sir... i use this one...

 

 

package Pocket;

import java.util.Enumeration;
import java.util.Vector;

import javax.microedition.pim.Contact;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;

import net.rim.blackberry.api.pdap.BlackBerryContact;
import net.rim.blackberry.api.pdap.BlackBerryContactList;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

class Scr extends MainScreen
{
public Scr() {
Vector v = getContacts();
Enumeration iterator = v.elements();
while (iterator.hasMoreElements()) {
String[] contact = (String[]) iterator.nextElement();
for (int i = 0; i < contact.length; i++)
add(new LabelField(contact[i]));
}

}

private Vector getContacts() {
Vector result = new Vector();
try {
BlackBerryContactList contactList = (BlackBerryContactList) PIM
.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
Enumeration enumx = contactList.items();
while (enumx.hasMoreElements()) {
BlackBerryContact c = (BlackBerryContact) enumx.nextElement();
String[] contact = new String[2];
if (contactList.isSupportedField(BlackBerryContact.NAME)) {
String[] name = c.getStringArray(BlackBerryContact.NAME, 0);
String firstName = name[Contact.NAME_GIVEN];
String lastName = name[Contact.NAME_FAMILY];
contact[0] = firstName + " " + lastName;
}
if (contactList.isSupportedField(BlackBerryContact.EMAIL)) {
StringBuffer emails = new StringBuffer();
int emailCount = c.countValues(BlackBerryContact.EMAIL);
for (int i = 0; i < emailCount; i++) {
String email = c.getString(BlackBerryContact.EMAIL, i);
if (email != null) {
emails.append(email.trim());
emails.append("; ");
}
}
contact[1] = emails.toString();
}
result.addElement(contact);
}
} catch (PIMException ex) {
ex.printStackTrace();
}
return result;
}
}

Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Button field should Work as brawse Button for contact list.

i would not use itens() as it is horribly slow. on a BB with 1k contacts the code loop takes several minutes, and as you execute it on the event thread your application would be terminated by the system watchdog (application not responding).

if you can, use choose.
otherwise look contacts up using itemsByName.

If you really have to use the whole addressbook you would have to copy it into your own data structure to use it, a task i did not assess as worth it when i checked requirements for my application.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter