Blackberry JAVA DEVELOPMENT ENVIRONMENT - - GPS AND MAPS - DEVELOPMENT GUIDE Manual do Utilizador Página 23

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 30
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 22
For RIM and BlackBerry partner use only. Beta documentation. Content and software are subject to change.
23
3: Displaying location information on a BlackBerry device
Open BlackBerry Maps to display the location for an address in the contact list
You can create a BlackBerry® Application that displays a map in BlackBerry Maps for the address of a contact in
the contact list. The address for the contact must be a valid address.
1. Import the javax.microedition.pim.PIM class and the javax.microedition.pim.Contact interface.
import javax.microedition.pim.PIM;
import javax.microedition.pim.Contact ;
2. Create a contact object.
Contact c = null;
3. In a try block, get the contact list.
try {
ContactList contactList = (ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST,
PIM.READ_WRITE);
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
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 BlackBerry Maps.
if (c == null) {
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments());
}
}
};
View a sample application that displays the location for an address in the address book
1. On a BlackBerry® device, open the address book.
Vista de página 22
1 2 ... 18 19 20 21 22 23 24 25 26 27 28 29 30

Comentários a estes Manuais

Sem comentários