Location picker sample app
The Location Picker sample application uses the LocationPicker API to list out the name, a description, and the qualified coordinates (latitude and longitude) of a geographical location on the screen of a BlackBerry device.
The sample application creates an array of LocationPicker.Picker objects, which act as containers for location picker objects that implement the interface, such as GPSLocationPicker and MapsLocationPicker. The sample application also looks for LocationPicker.Picker objects already existing on the device. These already existing LocationPicker objects are called global location pickers. Global location pickers are created in other applications, and register themselves with the LocationPicker API.
The sample application uses these LocationPicker.Picker objects to populate a single LocationPicker object. It then adds them to the screen, and makes them accessible from a menu.
This file defines two classes, the LocationPickerDemo class and its nested class, LocationPickerDemoScreen.
The LocationPickerDemo class extends the UiApplication class, and contains the following constructor and methods:
The LocationPickerDemoScreen class extends the MainScreen class, and implements the LocationPicker.Listener and FieldChangeListener interfaces. It contains the following constructor and methods:
This sample features the following classes:
This class provides a central LocationPicker object to store individual location pickers (such as GPSLocationPicker and MapsLocationPicker) in. All location pickers are added to the screen because they are extensions of the PopupScreen class.
LocationPicker also provides the functionality to register location pickers as global LocationPicker objects, allowing any application on the BlackBerry device to access them. The class has two nested interfaces, LocationPicker.Picker and LocationPicker.Listener.
The sample application is designed to showcase the LocationPicker class, and its nested interfaces. It creates an array of LocationPicker.Picker objects, then adds them to the LocationPicker object and pushes that object to the screen.
This class represents a landmark, or a known location. A LocationPicker.Picker object can contain a Landmark, which stores information about the name and coordinates of a location.
The sample application creates an array of Landmark objects to populate a SuggestedLocationPicker.
Install the sample app
In the BlackBerry Java Development Environment, open the workspace that you want to add the sample application to.
In the Files pane, right-click <workspace_name>.
Click Add project to <workspace_name>.
In the Add project to <workspace_name> dialog box, browse to the locationpickerdemo folder. The default location of this folder is C:\Program Files\Research In Motion\BlackBerry JDE 5.0.0\samples\com\rim\samples\device\ui\locationpickerdemo.
Click the LocationPickerDemo.jdp file.
The sample app is also available in github.
Run the sample app
In the BlackBerry Java Development Environment, in the workspace that you added the LocationPickerDemo project to, right-click LocationPickerDemo.
Click Build project.
On the taskbar, click Start > Applications > Research In Motion > BlackBerry JDE 5.0.0 > Device Simulator.
On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.
Click the LocationPickerDemo icon.