Interface IWPS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
abort()
Attempts to immediately cancel any operations that are executing in the background, before returning.WPSReturnCode
cancelAllGeoFences()
Cancel all geofences.WPSReturnCode
cancelGeoFence(WPSGeoFence.Handle handle)
Cancel a geofence.void
destroy()
void
getCertifiedLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, WPSCertifiedLocationCallback callback)
Requests certified geographic location updates.void
getIPLocation(WPSAuthentication authentication, WPSStreetAddressLookup addressLookup, boolean timeZoneLookup, IPLocationCallback callback)
Request geographic location information based on the IP address of the client making the request.void
getIPLocation(WPSAuthentication authentication, WPSStreetAddressLookup addressLookup, IPLocationCallback callback)
Deprecated.void
getLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, boolean timeZoneLookup, WPSLocationCallback callback)
Requests geographic location.void
getLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, WPSLocationCallback callback)
Deprecated.void
getOfflineLocation(WPSAuthentication authentication, byte[] key, byte[] token, WPSLocationCallback callback)
Requests geographic location based on a token collected at a different time.byte[]
getOfflineToken(WPSAuthentication authentication, byte[] key)
Retrieve an offline token based on the latest observed Wi-Fi access points and cell towers.void
getPeriodicLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, boolean timeZoneLookup, long period, int iterations, WPSPeriodicLocationCallback callback)
Requests periodic geographic location.void
getPeriodicLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, long period, int iterations, WPSPeriodicLocationCallback callback)
void
registerUser(WPSAuthentication authentication, WPSAuthentication newUser, RegistrationCallback callback)
Deprecated.void
setAuthentication(java.lang.String key, java.lang.String sku)
Set the user's authentication information.WPSGeoFence.Handle
setGeoFence(WPSGeoFence geofence, GeoFenceCallback callback)
Define a new geofence.void
setKey(java.lang.String key)
Set the user's API key.void
setLocalFilePaths(java.util.List<java.lang.String> paths)
Set the path to local files so location determination can be performed locally.void
setRegistrationUser(WPSAuthentication authentication)
Deprecated.void
setTiling(java.lang.String dirpath, long maxDataSizePerSession, long maxDataSizeTotal, TilingListener listener)
Setup tiling so location determination can be performed locally.void
tuneLocation(WPSAuthentication authentication, WPSLocation newLocation, TuneLocationCallback callback)
Tune the last location returned.
-
-
-
Method Detail
-
abort
void abort()
Attempts to immediately cancel any operations that are executing in the background, before returning.
-
destroy
void destroy()
- Since:
- 5.7
-
getIPLocation
@Deprecated void getIPLocation(WPSAuthentication authentication, WPSStreetAddressLookup addressLookup, IPLocationCallback callback)
Deprecated.Request geographic location information based on the IP address of the client making the request.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.addressLookup
- the street address lookup type desired.callback
- anIPLocationCallback
-
getIPLocation
void getIPLocation(WPSAuthentication authentication, WPSStreetAddressLookup addressLookup, boolean timeZoneLookup, IPLocationCallback callback)
Request geographic location information based on the IP address of the client making the request.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.addressLookup
- the street address lookup type desired.timeZoneLookup
- request timezone lookup in addition to latitude/longitude lookup.callback
- anIPLocationCallback
- Since:
- 5.0
-
getLocation
@Deprecated void getLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, WPSLocationCallback callback)
Deprecated.Requests geographic location.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.streetAddressLookup
- request street address lookup in addition to latitude/longitude lookup.callback
- aWPSLocationCallback
-
getLocation
void getLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, boolean timeZoneLookup, WPSLocationCallback callback)
Requests geographic location.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.streetAddressLookup
- request street address lookup in addition to latitude/longitude lookup.timeZoneLookup
- request timezone lookup in addition to latitude/longitude lookup.callback
- aWPSLocationCallback
- Since:
- 5.0
-
getPeriodicLocation
@Deprecated void getPeriodicLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, long period, int iterations, WPSPeriodicLocationCallback callback)
Deprecated.Requests periodic geographic location.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.streetAddressLookup
- request street address lookup in addition to latitude/longitude lookup. Note that street address lookup is only performed when the location is determined by the remote server (network-centric model), not when the location is determined locally.iterations
- number of time a location is to be reported. A value of zero indicates an unlimited number of iterations.period
- maximum time in milliseconds between location reports.
WPS will invoke the callback at least every period, either with a location update or with an error if no location can be determined. WPS may report location updates more often than the specified period if a new or better location becomes available within a given period.
This parameter is also used to specify the preferred Wi-Fi scan period, which WPS may override for optimal performance and power savings.callback
- aWPSPeriodicLocationCallback
-
getPeriodicLocation
void getPeriodicLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, boolean timeZoneLookup, long period, int iterations, WPSPeriodicLocationCallback callback)
Requests periodic geographic location.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.streetAddressLookup
- request street address lookup in addition to latitude/longitude lookup. Note that specifying a street address lookup will enforce locations to be determined by the remote server (network-centric model).timeZoneLookup
- request timezone lookup in addition to latitude/longitude lookup. Note that specifying a time zone lookup will enforce locations to be determined by the remote server (network-centric model).iterations
- number of time a location is to be reported. A value of zero indicates an unlimited number of iterations.
Using this parameter to set a finite number of iterations is not recommended for new applications. The preferred way to bound the duration of the location request is to explicitly interrupt it by returningWPSContinuation.WPS_STOP
or invokingabort()
.period
- maximum time in milliseconds between location reports.
WPS will invoke the callback at least every period, either with a location update or with an error if no location can be determined. WPS may report location updates more often than the specified period if a new or better location becomes available within a given period.
This parameter is also used to specify the preferred Wi-Fi scan period, which WPS may override for optimal performance and power savings.callback
- aWPSPeriodicLocationCallback
- Since:
- 5.0
-
getCertifiedLocation
void getCertifiedLocation(WPSAuthentication authentication, WPSStreetAddressLookup streetAddressLookup, WPSCertifiedLocationCallback callback)
Requests certified geographic location updates. To stop receiving updates, either returnWPSContinuation.WPS_STOP
from the callback, or invokeabort()
.- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.streetAddressLookup
- request street address lookup in addition to latitude/longitude lookup.callback
- aWPSCertifiedLocationCallback
-
getOfflineToken
byte[] getOfflineToken(WPSAuthentication authentication, byte[] key)
Retrieve an offline token based on the latest observed Wi-Fi access points and cell towers. This token can be saved and converted to a location later by callinggetOfflineLocation
.A sensible time to call
getOfflineToken
is from eithergetLocation
orgetPeriodicLocation
callback with aWPS_ERROR_SERVER_UNAVAILABLE
error code (indicating the device is offline).Offline tokens are only valid for 90 days after they are generated. Attempting to redeem a token more than 90 days old will result in an error.
Sample Code:
final byte[] token = _wps.getOfflineToken(null, null); if (token == null) { System.err.println("no token to save"); } else { // save the token in persistent storage // ... }
- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.key
- deprecated and must be set tonull
- Returns:
- the offline token or null if XPS does not have enough information to be able to determine a location later.
- Since:
- 4.5
- See Also:
getOfflineLocation(WPSAuthentication, byte[], byte[], WPSLocationCallback)
-
getOfflineLocation
void getOfflineLocation(WPSAuthentication authentication, byte[] key, byte[] token, WPSLocationCallback callback)
Requests geographic location based on a token collected at a different time.This method may be called while a getLocation or getPeriodicLocation call is in progress. If it is called while another getOfflineLocation call is already in progress, then that one will be aborted.
Offline tokens are only valid for 90 days after they are generated. Attempting to redeem a token more than 90 days old will result in an error.
Although a token can be collected when a location has been calculated
getOfflineLocation
is not guaranteed to return a location with that same token.Sample Code:
// restore token stored earlier final byte[] token = ... ; _wps.getOfflineLocation(null, null, token, new WPSLocationCallback() { public void handleWPSLocation(final WPSLocation location) { // use the location // ... } public WPSContinuation handleError(final WPSReturnCode error) { System.err.println("getOfflineLocation() failed: "+error); // ... return WPSContinuation.WPS_STOP; } public void done() { //... } });
- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.key
- deprecated and must be set tonull
token
- the token to be converted to a location.callback
- aWPSLocationCallback
.- Since:
- 4.5
- See Also:
getOfflineToken(WPSAuthentication, byte[])
-
setKey
void setKey(java.lang.String key)
Set the user's API key.Make sure to call this method before making any other calls, such as during initialization of the application.
After this call you should pass
null
asauthentication
to other calls likegetLocation
.Must not be used in conjunction with
setAuthentication(java.lang.String, java.lang.String)
.- Parameters:
key
- an existing user's API key.- Throws:
java.lang.IllegalArgumentException
- if the key is malformed- Since:
- 4.9
-
setAuthentication
void setAuthentication(java.lang.String key, java.lang.String sku)
Set the user's authentication information.Make sure to call this method before making any other calls, such as during initialization of the application.
After this call you should pass
null
asauthentication
to other calls likegetLocation
.Must not be used in conjunction with
setKey(java.lang.String)
.- Parameters:
key
- an existing user's API key.sku
- product's SKU.- Throws:
java.lang.IllegalArgumentException
- if the key or SKU string is malformed- Since:
- 5.8
-
setRegistrationUser
@Deprecated void setRegistrationUser(WPSAuthentication authentication)
Deprecated.Replaced bysetKey(java.lang.String)
andsetAuthentication(java.lang.String, java.lang.String)
. This method is no longer supported starting with version 5.5.Set the user's authentication information.Make sure to call this method before making any other calls, such as during initialization of the application.
After this call you should pass
null
asauthentication
to other calls likegetLocation
.Must not be used in conjunction with
setKey(java.lang.String)
.- Parameters:
authentication
- an existing user's authentication information.- Since:
- 4.8
-
registerUser
@Deprecated void registerUser(WPSAuthentication authentication, WPSAuthentication newUser, RegistrationCallback callback)
Deprecated.Replaced bysetKey(java.lang.String)
andsetAuthentication(java.lang.String, java.lang.String)
. This method is no longer supported starting with version 5.5.Register a new user.New applications are encouraged to simply use the auto-registration feature by calling registerUser, such as during initialization of the application.
For example:// Info from Skyhook private static final String WPS_USERNAME = "myusername"; private static final String WPS_REALM = "myrealm"; private final WPSAuthentication _wpsUser = new WPSAuthentication(WPS_USERNAME, WPS_REALM); void wpsInit() { _wps.registerUser(_wpsUser, null, new RegistrationCallback() { public void handleSuccess() { // ... } public WPSContinuation handleError(final WPSReturnCode error) { // ... return WPSContinuation.WPS_CONTINUE; } public void done() { //... } }); }
Applications that still want to control how usernames are generated can continue to do so as they did before since version 4.2 is backward compatible with 4.1. For example:// Info from Skyhook private static final String WPS_USERNAME = "myusername"; private static final String WPS_REALM = "myrealm"; // Where generateUsername() returns your own generated username private final WPSAuthentication _wpsUser = new WPSAuthentication(generateUsername(), WPS_REALM); void wpsInit() { // Where readUsername() returns the saved username, or null if // there isn't one saved if (_wpsUser.getUsername().equals(readUsername())) { // user already registered (and matched generated username) return; } _wps.registerUser(new WPSAuthentication(WPS_USERNAME, WPS_REALM), _wpsUser, new RegistrationCallback() { public void handleSuccess() { // ... saveUsername(_wpsUser.getUsername()); } public WPSContinuation handleError(final WPSReturnCode error) { // ... return WPSContinuation.WPS_CONTINUE; } public void done() { //... } }); }
Note that the generated username should be stable -- ie. remain constant over time, every time it is generated -- to avoid unnecessary re-registrations. Care should be taken when generating a username to protect the privacy of the user, and should not contain any personally identifiable information.
Now whenever your application needs to determine a location, it can simply call getLocation() or getPeriodicLocation(), even if registerUser() is still ongoing, or if it has failed. For example:_wps.getLocation(_wpsUser, WPSStreetAddressLookup.WPS_FULL_STREET_ADDRESS_LOOKUP new WPSLocationCallback() {...});
- Parameters:
authentication
- an existing user's authentication information.newUser
- the new user's authentication information or null to trigger auto-registration.callback
- aRegistrationCallback
-
tuneLocation
void tuneLocation(WPSAuthentication authentication, WPSLocation newLocation, TuneLocationCallback callback)
Tune the last location returned. The device must be at the location specified innewLocation
during the entire duration of this call. Note that pure GPS locations will not reflect any tuning.Tuning is not an effective strategy for trying to make small adjustments to a location. It is best used for adding to our coverage or fixing results that are off by hundreds of meters.
- Parameters:
authentication
- must benull
for new applications that usesetKey(java.lang.String)
orsetAuthentication(java.lang.String, java.lang.String)
, otherwise set to the user's authentication information.newLocation
- the tuned locationcallback
- aTuneLocationCallback
-
setLocalFilePaths
void setLocalFilePaths(java.util.List<java.lang.String> paths)
Set the path to local files so location determination can be performed locally.- Parameters:
paths
- a list of compressed positioning data file paths. This list replaces all previous values. Usenull
to clear and release local files.
-
setTiling
void setTiling(java.lang.String dirpath, long maxDataSizePerSession, long maxDataSizeTotal, TilingListener listener)
Setup tiling so location determination can be performed locally. Tiles are typically less then 50KB in size, so to download an area of 3x3 tiles for each session you would setmaxDataSizePerSession
to 450KB, i.e. 460,800. It is recommended thatmaxDataSizePerSession
be a factor of 2 - 10 smaller thanmaxDataSizeTotal
, so that tiles from several areas can be cached.- Parameters:
dirpath
- the path to a directory to store tiles.maxDataSizePerSession
- the maximum size of data downloaded per session, in bytes. A value of 0 disables any further tile downloads.maxDataSizeTotal
- the maximum size of all stored tiles, in bytes. A value of 0 causes all stored tiles to be deleted.listener
- the callback function to control the tile download. By default, all tiles are downloaded.
-
setGeoFence
WPSGeoFence.Handle setGeoFence(WPSGeoFence geofence, GeoFenceCallback callback)
Define a new geofence.Sample Code:
final WPSGeoFence geofence = new WPSGeoFence(42.1234, -71.5678, 100, WPSGeoFence.Type.WPS_GEOFENCE_ENTER, 0); final WPSGeoFence.Handle handle = _wps.setGeoFence(geofence, new MyGeoFenceCallback()); if (handle == null) System.err.println("setGeoFence() failed"); _wps.getPeriodicLocation(null, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, 60 * 60 * 1000, 0, new MyPeriodicLocationCallback());
- Parameters:
geofence
- the geofence to monitorcallback
- theGeoFenceCallback
to invoke when this geofence is triggered- Returns:
- a
WPSGeoFence.Handle
that can be used to cancel geofence or null if geofence cannot be registered. - Since:
- 4.4
- See Also:
cancelGeoFence(WPSGeoFence.Handle)
-
cancelGeoFence
WPSReturnCode cancelGeoFence(WPSGeoFence.Handle handle)
Cancel a geofence.- Parameters:
handle
- of geofence to cancel- Returns:
- a
WPSReturnCode
.
WPS_GEOFENCE_ERROR
indicates the geofence for this handle isn't defined. - Since:
- 4.4
- See Also:
setGeoFence(WPSGeoFence, GeoFenceCallback)
-
cancelAllGeoFences
WPSReturnCode cancelAllGeoFences()
Cancel all geofences.- Returns:
- a
WPSReturnCode
- Since:
- 4.4
- See Also:
setGeoFence(WPSGeoFence, GeoFenceCallback)
-
-