background image

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

Содержание GPS and BlackBerry Maps

Страница 1: ...GPS and BlackBerry Maps Version 4 7 0 Development Guide...

Страница 2: ...SWD 596846 1209055709 001...

Страница 3: ...adings using the cell site mode 7 Get GPS information during a call 7 Get location information updates 8 Change the criteria for obtaining location information 8 2 BlackBerry Maps location information...

Страница 4: ...was unsuccessful 26 Open BlackBerry Maps from the browser 26 Clearing data from the map 27 Clear data from a location document with an id attribute 27 Clear data from all location documents with an i...

Страница 5: ...ocation Criteriaclass invoketheappropriatesetmethods andthenpasstheinstance to LocationProvider getInstance cell site Use this mode to get location information from cell site towers This mode allows a...

Страница 6: ...latitudinal accuracy is not required 4 Invoke criteria setCostAllowed true to specify that this mode can incur cost 5 Invoke criteria setPreferredPowerConsumption int level using one of POWER_USAGE_ME...

Страница 7: ...ormation using the GPS receiver on a BlackBerry device Task Steps Specify a level of accuracy with no cost and no power consumption a Invokecriteria setHorizontalAccuracy int accuracy using an integer...

Страница 8: ...n Specify a response time for getting the location of the BlackBerry device Invoke Criteria setPreferredResponseTime and specify the response time in milliseconds Get the location information for a Bl...

Страница 9: ...ed GPS information Invoke Location getTimeStamp The time is retrieved from the GPS receiver on the BlackBerry device Location location provider getLocation 1 myLocation getTimeStamp Maintain a connect...

Страница 10: ...teria 2 Invoke the setHorizontalAccuracy setVerticalAccuracy setCostAllowed and setPreferredPowerConsumption methods of the new Criteria object to specify the new criteria 3 Invoke LocationProvider re...

Страница 11: ...erry Maps is included on BlackBerry devices that run BlackBerry Device Software version 4 2 or later Displaying location information on a BlackBerry device Displaying location information in BlackBerr...

Страница 12: ...nt represents the starting point of a route while the second location element represents the ending point of a route You can only use the x and y attributes in a location element that is nested within...

Страница 13: ...g email address no 4 2 1 or later categories String category no 4 2 1 or later rating String rating information between 0 and 5 no 4 2 1 or later Create a location document to display location informa...

Страница 14: ...s object that does not contain any arguments View a sample application that displays the default map 1 From the BlackBerry Integrated Development Environment launch the BlackBerryMapsDemo project 2 In...

Страница 15: ...n document location lon 7938675 lat 4367022 label Toronto ON description Toronto zoom 10 location document 3 Invoke invokeApplication using the APP_TYPE_MAPS constant parameter a new MapsArguments obj...

Страница 16: ...e Invoke net rim blackberry api invoke MapsArguments 2 Create a String that contains location information for multiple locations String document location document location lon 8030000 lat 4326000 labe...

Страница 17: ...enu and click View Multiple Locations Open BlackBerry Maps to display a route between locations on a map 1 Import the following classes net rim blackberry api invoke Invoke net rim blackberry api invo...

Страница 18: ...ents ARG_LOCATION_DOCUMENT document View a sample application that displays a route between locations on a map 1 From the BlackBerry Integrated Development Environment launch the BlackBerryMapsDemo pr...

Страница 19: ...APS new MapsArguments mapView View a sample application that displays a custom map view 1 From the BlackBerry Integrated Development Environment launch the BlackBerryMapsDemo project 2 In the BlackBer...

Страница 20: ...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_T...

Страница 21: ...rgument in the main method of the BlackBerry Application 6 Select Auto run on startup 7 Select System module 8 Click OK 9 Import the following classes import net rim device api ui import net rim devic...

Страница 22: ...e main method register a menu item with BlackBerry Maps public static void main String args if args null args length 0 if args 0 equals startup Register an ApplicationMenuItem when the BlackBerry smar...

Страница 23: ...mv The int values that getLatitude and getLongitude return are 100 000 times the values specified by WGS84 _latitudeField new BasicEditField Latitude _mv getLatitude 100000 0 9 BasicEditField FILTER_R...

Страница 24: ...iew setLatitude latitude _mapview setLongitude longitude Invoke BlackBerry Maps with a MapView object Invoke invokeApplication Invoke APP_TYPE_MAPS new MapsArguments _mapview close catch RuntimeExcept...

Страница 25: ...ion based services A MapField gets data either from a map server for location based services or the BlackBerry device with BlackBerry Maps installed If location information is not present on the Black...

Страница 26: ...MapField Invoke getRotation Converting latitudinal and longitudinal coordinates to pixel values You can create a BlackBerry device application to convert latitudinal and longitudinal coordinates to pi...

Страница 27: ...al and longitudinal data for the address If the request is unsuccessful the server throws aLocatorException exception that contains the reason for the unsuccessful request A BlackBerry device applicat...

Страница 28: ...rCode try catch LocationException e System err println LocationException e getErrorCode Open BlackBerry Maps from the browser A BlackBerry device user can use the browser on a BlackBerry device to acc...

Страница 29: ...you send to BlackBerry Maps configure the clear attribute to the value of the id attribute of the location document that contains information for Kitchener String document lbs clear Kit location lon...

Страница 30: ...d attribute set to a value Create a String that configures the clear attribute to a comma delimited list of ids String document lbs clear MONTREAL OTTAWA location lon 7938675 lat 4367022 label Toronto...

Страница 31: ...tem JSR Java Specification Request MIME Multipurpose Internet Mail Extensions NMEA National Marine Electronics Association PDE Position Determination Entity SIM Subscriber Identity Module WGS World Ge...

Страница 32: ...Provide feedback 4 To provide feedback on this deliverable visit www blackberry com docsfeedback Development Guide Provide feedback 30...

Страница 33: ...u in a timely manner or at all This documentation might contain references to third party sources of information hardware or software products or services including components and content such as cont...

Страница 34: ...UDING AIRTIME SERVICE PROVIDERS AND THEIR RESPECTIVE DIRECTORS EMPLOYEES AND INDEPENDENT CONTRACTORS IN ADDITION TO THE LIMITATIONS AND EXCLUSIONS SET OUT ABOVE IN NO EVENT SHALL ANY DIRECTOR EMPLOYEE...

Страница 35: ...TOSUPERSEDEANYEXPRESSWRITTENAGREEMENTSORWARRANTIES PROVIDED BY RIM FOR PORTIONS OF ANY RIM PRODUCT OR SERVICE OTHER THAN THIS DOCUMENTATION Research In Motion Limited 295 Phillip Street Waterloo ON N2...

Отзывы: