Help Center
Local Navigation
- GPS overview
- Specifying the GPS mode
- Retrieving a location provider
- Retrieving the location of a BlackBerry device
- Geocoding and reverse geocoding
- BlackBerry Maps
- Glossary
- Provide feedback
- Document revision history
- Legal notice
BlackBerry Manuals & Help
>
Developer Documentation
>
Java Development Guides and API Reference
>
Development Guide
Location-Based Services - BlackBerry Java Application - 5.0
Retrieve a location provider by using the BlackBerryLocationProvider class
- Import the required classes.
import net.rim.device.api.gps.*; import javax.microedition.location.*;
- Create a class and a constructor.
public class handleGPS { static BlackBerryCriteria myCriteria; public handleGPS() { } } - In the constructor, create a try/catch block. In the block, create an instance of the BlackBerryCriteria class and pass the GPS mode to the constructor. Create a second try/catch block, then create an instance of the BlackBerryLocationProvider
class by invoking getInstance()
to retrieve an instance of the BlackBerryCriteria
object.
try { myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_ASSIST); try { BlackBerryLocationProvider myProvider = (BlackBerryLocationProvider) LocationProvider.getInstance(myCriteria); } catch ( LocationException lex ) { return; } } catch ( UnsupportedOperationException ex ) { return; } } }
Parent topic: Retrieving a location provider