Simple Location API features:
SimpleLocationListener interface.
Examples
Single location fix in default mode
try{
simpleProvider = new SimpleLocationProvider();
} catch(LocationException le){ // thrown if the default mode MODE_OPTIMAL is not available.
...
}
BlackBerryLocation location = simpleProvider.getLocation(120); // 120 seconds timeout
Single location fix in a specified mode:
try{
simpleProvider = new SimpleLocationProvider(SimpleLocationProvider.MODE _GPS);
} catch(LocationException le){ // thrown if the selected mode (in this case MODE_GPS) is not available.
...
}
BlackBerryLocation location = simpleProvider.getLocation(120); // 120 seconds timeout
Tracking session in default mode
try{
simpleProvider = new SimpleLocationProvider();
} catch(LocationException le){ // thrown if the default mode MODE_OPTIMAL is not available.
...
}
// Location fixes will be delivered to simpleLocationListenerImpl (an implementation of SimpleLocationListener) every 6 seconds.
simpleProvider.addSimpleLocationListener(simpleLoc ationListenerImpl, 6);
Tracking session in a specific mode
try{
simpleProvider = new SimpleLocationProvider(SimpleLocationProvider.MODE _GPS);
} catch(LocationException le){ // thrown if the selected mode (in this case MODE_GPS) is not available.
...
}
// Location fixes will be delivered to simpleLocationListenerImpl (an implementation of SimpleLocationListener) every 6 seconds.
simpleProvider.addSimpleLocationListener(simpleLoc ationListenerImpl, 6);
rimx.location.simplelocation
| Field Summary | |
|---|---|
static int |
MODE_GEOLOCATION Operates strictly in Geolocation mode. |
static int |
MODE_GEOLOCATION_CELL Operates strictly in cell based Geolocation mode. |
static int |
MODE_GEOLOCATION_WLAN Operates strictly in WLAN based Geolocation mode. |
static int |
MODE_GPS Operates strictly in GPS (aka Standalone/Autonomous) mode. |
static int |
MODE_OPTIMAL Operates in both Geolocation and GPS mode based on availability. |
| Constructor Summary | |
|---|---|
SimpleLocationProvider() Initializes the default SimpleLocationProvider in MODE_OPTIMAL. |
|
SimpleLocationProvider(int mode) Initializes a SimpleLocationProvider in the specified mode. |
|
| Method Summary | |
|---|---|
void |
addSimpleLocationListener(SimpleLocationListener listener, int interval) Adds a SimpleLocationListener implementation to this SimpleLocationProvider and starts a tracking session. |
int |
getGeolocationTimeout() Gets the current value of Geolocation timeout. |
int |
getGPSTimeout() Gets the current value of GPS timeout. |
BlackBerryLocation |
getLastKnownLocation() Returns the last known location. |
BlackBerryLocation |
getLocation(int timeout) Gets a single location fix and stops. |
int |
getMaxRetryDelay() Gets the current value of maxRetryDelay. |
int |
getMode() Returns the current mode of this SimpleLocationProvider |
int |
getRetryFactor() Gets the current retry factor. |
int |
getTrackingInterval() Gets the current tracking interval. |
void |
locationUpdated(LocationProvider provider, Location location) This is used by this API internally and must NOT be called. |
void |
log(String msg) Logs a message to standard output as well as to the device eventlog. |
void |
providerStateChanged(LocationProvider provider, int newState) This is used by this API internally and must NOT be called. |
void |
removeSimpleLocationListener() Removes the current SimpleLocationListener implementation from this and stops tracking session. |
void |
restart() Triggers an immediate retry to get location fixes again. |
void |
setGeolocationTimeout(int timeout) Sets the Geolocation timeout. |
void |
setGPSTimeout(int timeout) Sets the GPS timeout. |
void |
setMaxRetryDelay(int delay) Sets the maxRetryDelay value that dictates the maximum time this provider can wait until a retry is performed. |
void |
setMode(int mode) Sets/changes the current mode of this SimpleLocationProvider. |
void |
setRetryFactor(int factor) Sets the retry factor to the specified value. |
void |
setTrackignInterval(int interval) Sets the interval used between fixes in a tracking session. |
rimx.location.simplelocation
Implement this interface to listen for events triggered by SimpleLocationProvider for a tracking session. Implementation of this interface should be registered with SimpleLocationProvider by calling SimpleLocationProvider.addSimpleLocationListener(S. Otherwise, no tracking session will be started and no location fixes will be delivered to this listener interface. Only one SimpleLocationListener implementation can be registered with a SimpleLocationProvider.
// The following call registers simpleLocationListenerImpl (aSimpleLocationListenerimplementation) to receive location updates every 5 seconds. simpleLocationProvider.addSimpleLocationListener(simpleLocationListenerImpl, 5); // The following call removes simpleLocationListenerImpl (a SimpleLocationListenerimplementation) and stops any further location updates. simpleLocationProvider.removeSimpleLocationListener();
| Field Summary | |
|---|---|
static int |
EVENT_ACQUIRING_LOCATION Triggered when the SimpleLocationProvider starts/restarts to acquire a location fix. |
static int |
EVENT_CELL_GEOLOCATION Triggered when a location is obtained via cell tower based geolocation. |
static int |
EVENT_GPS_LOCATION Triggered when a location is obtained via GPS. |
static int |
EVENT_LOCATION_FAILED Triggered when obtaining a location fix fails within the specified timeout - (See SimpleLocationProvider.setGeolocationTimeout(int) and SimpleLocationProvider.setGPSTimeout(int)). |
static int |
EVENT_UNKNOWN_MODE Triggered when a valid location is obtained but the mode is unknown. |
static int |
EVENT_WLAN_GEOLOCATION Triggered when a location is obtained via wlan based geolocation. |
| Method Summary | |
|---|---|
void |
debugLog(String msg) Called when a debug message is available. |
void |
locationEvent(int event, Object eventData) Triggers one of the EVENT_* events defined in this interface. |