4.
Place the items from the contact list into an enumeration.
Enumeration enumContact = contactList.items();
int notFinished = 1;
5.
Create a
While
loop to iterate through all the items in the enumeration.
while ((enumContact.hasMoreElements()) && ( notFinished == 1)) {
c = (Contact)enumContact.nextElement();
int[] fieldIds = c.getFields();
int id;
6.
Search for the first contact with a valid city and region and display the address information for this contact in the BlackBerry®
Maps.
if (c.countValues(Contact.ADDR) > 0) {
String address[] = c.getStringArray(Contact.ADDR,0);
if ((address[Contact.ADDR_LOCALITY] != null) && (address
[Contact.ADDR_REGION] != null)) {
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new
MapsArguments(c,0));
notFinished = 0;
}
}
}
} catch (PIMException e) {
}
7.
If a contact address is not found, display the default map in the BlackBerry Maps.
if © == null) {
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments());
}
}
};
View a sample application that displays the location for an address in the contact list
Before you begin:
On a BlackBerry® device, open the contact list. If there are no addresses in the contact list, the sample will display the default
view in the BlackBerry® Maps.
1.
Open the BlackBerry® Integrated Development Environment.
2.
Launch the
BlackBerryMapsDemo
project.
3.
In the BlackBerry Smartphone Simulator, click
BlackBerry Maps Demo
.
4.
Open the menu and click
Invoke Contact
.
5.
Open the menu and click
View Map
.
Development Guide
Displaying location information on a BlackBerry device
18