Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

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.

File name



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:

  • main(String[] args): provides the entry point to the sample application and starts the main thread using UiApplication.enterEventDispatcher()
  • LocationPickerDemo(): constructs a new LocationPickerDemo object which pushes a LocationPickerDemoScreen onto the display stack

The LocationPickerDemoScreen class extends the MainScreen class, and implements the LocationPicker.Listener and FieldChangeListener interfaces. It contains the following constructor and methods:

  • LocationPickerDemoScreen(): initializes the screen by creating LabelField, ButtonField and LocationPicker.Picker objects used in the sample application
  • locationPicked(LocationPicker.Picker picker, Landmark location): implements of the LocationPicker.Listener interface, and displays the name, description, latitude and longitude stored in the LocationPicker.Picker object when selected by the user
  • fieldChanged(Field field, int context): implements the FieldChangeListener class, and listens for the user to press the "Choose location" button, then displays the menu when the button is pressed

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.

Click Open.

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.