|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j4me.bluetoothgps.LocationProvider
org.j4me.bluetoothgps.MockLocationProvider
public class MockLocationProvider
A LocationProvider
for testing MIDlets. Methods on this class
can set locations manually.
Make sure the MockLocationProvider
is not referenced in
anything but your test code. Then the obfuscator will remove this class
from the final Jar.
LocationProvider
Field Summary |
---|
Fields inherited from class org.j4me.bluetoothgps.LocationProvider |
---|
AVAILABLE, OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE |
Constructor Summary | |
---|---|
MockLocationProvider()
Constructs a mock location provider. |
Method Summary | |
---|---|
void |
close()
This is a no-op for the mock location provider. |
protected Location |
getLastKnownLocationToProvider()
Returns the last known location by the provider. |
Location |
getLocation(int timeout)
Gets the last location set. |
int |
getState()
Returns the state of this mock provider. |
void |
reset()
Resets the LocationProvider . |
void |
setLocation(QualifiedCoordinates coordinates,
float speed)
Sets a new location. |
void |
setLocationListener(LocationListener locationlistener,
int interval,
int timeout,
int maxAge)
Sets the listener that gets called when the setLocation
and setState methods are called. |
void |
setState(int state)
Sets the state of the mock location provider. |
Methods inherited from class org.j4me.bluetoothgps.LocationProvider |
---|
discoverBluetoothDevices, getInstance, getLastKnownLocation, supportsBluetoothAPI, supportsLocationAPI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockLocationProvider()
Method Detail |
---|
public void setState(int state)
setLocationListener
method, it
will get notified of the state change. If state
is the
same as getState
this method has no effect.
The initial provider state is
OUT_OF_SERVICE
. If
setLocation
is called it will automatically make the state
AVAILABLE
and call the registered listener's
providerStateChanged
method before calling its
locationUpdated
.
state
- is the new provider state. It must be one of
OUT_OF_SERVICE
, TEMPORARILY_UNAVAILABLE
, or
AVAILABLE
.
public void setLocation(QualifiedCoordinates coordinates, float speed)
setLocationListener
method, it will get notified of the
locationUpdated
method.
coordinates
- is the new location.speed
- is the new speed in meters per second.public int getState()
OUT_OF_SERVICE
, but can be set using the setState
method. After the setLocation
method is called this
automatically becomes AVAILABLE
getState
in class LocationProvider
LocationProvider.getState()
public Location getLocation(int timeout) throws LocationException, java.lang.InterruptedException
getLocation
in class LocationProvider
timeout
- - a timeout value in seconds. -1 is used to indicate that the
implementation shall use its default timeout value for this provider.
Location
object
LocationException
- - if the location couldn't be retrieved or if the
timeout period expired
java.lang.InterruptedException
- - if the operation is interrupted by calling
reset()
from another threadLocationProvider.getLocation(int)
protected Location getLastKnownLocationToProvider()
getLastKnownLocationToProvider
in class LocationProvider
null
is returned if the implementation
doesn't have any previous location information.
java.lang.SecurityException
- - if the calling application does not have a
permission to query the location informationLocationProvider.getLastKnownLocationToProvider()
public void setLocationListener(LocationListener locationlistener, int interval, int timeout, int maxAge)
setLocation
and setState
methods are called.
setLocationListener
in class LocationProvider
locationlistener
- - the listener to be registered. If set to null
the registration of any previously set listener is cancelled.interval
- - the interval in seconds. -1 is used for the default
interval of this provider. 0 is used to indicate that the
application wants to receive only provider status updates and not
location updates at all.timeout
- - timeout value in seconds, must be greater than 0. if the
value is -1, the default timeout for this provider is used. Also,
if the interval is -1 to indicate the default, the value of this
parameter has no effect and the default timeout for this provider
is used. If the interval is 0, this parameter has no effect.maxAge
- - maximum age of the returned location in seconds, must be
greater than 0 or equal to -1 to indicate that the default maximum
age for this provider is used. Also, if the interval is -1 to
indicate the default, the value of this parameter has no effect
and the default maximum age for this provider is used. If the
interval is 0, this parameter has no effect.LocationProvider.setLocationListener(org.j4me.bluetoothgps.LocationListener, int, int, int)
public void reset()
LocationProvider
LocationProvider
.
All pending synchronous location requests will be aborted and any blocked
getLocation
method calls will terminate with
InterruptedException
.
Applications can use this method e.g. when exiting to have its threads freed from blocking synchronous operations.
reset
in class LocationProvider
LocationProvider.reset()
public void close()
close
in class LocationProvider
LocationProvider.close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |