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

Use Remote Address Lookup through coding

by BlackBerry Development Advisor ‎02-16-2010 09:10 AM - edited ‎09-16-2010 03:00 PM (2,728 Views)

Summary

 

This article applies to the following:

 

  • BlackBerry® Java™ Development Environment (JDE) 4.0
  • BlackBerry Device Software 4.0

Description

 

Users with an account on the BlackBerry Enterprise Server™ can do a remote address lookup of contacts in the corporate address book using a BlackBerry wireless device. Third-party applications are also able to take advantage of this functionality using the Personal Digital Assistant Profile (PDAP) application programming interfaces (API) that appear below.

First the application must implement the RemoteLookupListener, so it will be notified when remote lookups return a set of results.

 

 

final class RemoteLookupDemo extends UiApplication implements RemoteLookupListener

 

The application implementing the RemoteLookupListener interface must also implement any methods that are part of that interface. The only method in the interface is the items() method. The items() method is called when a lookup has a set of results: valid or invalid. An enumeration of Contact objects is passed into the method with the results.

//this sample reads through the enumeration of contacts

 

 

//this sample reads through the enumeration of contacts

//and counts the number of contacts that were returned

public void items(Enumeration results) {

int count = 0;

while (results.hasMoreElements()) {

//alternatively you can do

//Contact contact = (Contact)results.nextElement();

//this would return the contact for manipulation

results.nextElement();

++count;

}

System.out.println("Number of Contacts: " + count);

}

 


Once the application can receive the remote lookup results, the application can perform the actual lookup.

 

try {

//retrieve an instance of PIM

PIM pim = PIM.getInstance();

//open the contact list for read/write permissions

BlackBerryContactList contactList = (BlackBerryContactList)

pim.openPIMList(PIM.CONTACT_LIST

,PIM.READ_WRITE);

//use the lookup method specifying the partial name

//to perform the remote address lookup on

contactList.lookup("Joe", this);

} catch (Exception ex) {

System.out.println(ex.toString());

}

 

Contributors
Users Online
Currently online: 4 members 903 guests
Please welcome our newest community members: