public abstract class IALocationManager
extends java.lang.Object
This class provides access to IndoorAtlas location services. The methods of this class must be called from the application main thread only.
Any conditions that prevent the manager from running are logged with android.util.Log
using log tag IASDK
.
Basic usage:
protected void onCreate(Bundle bundle) { super.onCreate(bundle) mLocationManager = IALocationManager.create(context); } protected void onDestroy() { mLocationManager.destroy(); super.onDestroy(); } protected void onResume() { super.onResume(); mLocationManager.requestLocationUpdates(IALocationRequest.create(), this); } protected void onPause() { mLocationManager.removeLocationUpdates(this); super.onPause(); } public void onLocationChanged(IALocation location) { // do something interesting with the new update } public void onStatusChanged(String provider, int status, Bundle extras) { // do something with the new status }Monitor geofences:
protected void onCreate(Bundle bundle) { super.onCreate(bundle) mLocationManager = IALocationManager.create(context); mLocationManager.requestLocationUpdates(IALocationRequest.create(), this); // Create edges with unique clockwise (lat, lon) points ListMonitor wayfinding route changes:edges = Arrays.asList(new double[][]{{59.8, 20.3}, {64.3, 20.7}, {63.7, 32.1}, {59.2, 29.8}}); // Create the geofence for 10 seconds in floor number 1 IAGeofence geofence = new IAGeofence.Builder() .withEdges(edges) .withFloor(1) .withId("This is a geofence for testing") .withExpirationDuration(10000) .withTransitionType(IAGeofence.GEOFENCE_TRANSITION_ENTER | IAGeofence.GEOFENCE_TRANSITION_EXIT) mLocationManager.addGeofences(new IAGeofenceRequest.Builder() .withGeofence(geofence) .withInitialTrigger(IAGeofenceRequest.INITIAL_TRIGGER_ENTER) .build(), this); } public void onGeofencesTriggered(IAGeofenceEvent geofenceEvent) { // Do something with the triggered geofences in geofenceEvent }
protected void onCreate(Bundle bundle) { super.onCreate(bundle) mLocationManager = IALocationManager.create(context); mLocationManager.requestLocationUpdates(IALocationRequest.create(), this); IAWayfindingRequest request = new IAWayfindingRequest() .withLatitude(60.1692229) .withLongitude(24.9326988) .withFloor(1); mLocationManager.requestWayfindingUpdates(request, this); } public void onWayfindingUpdate(IARoute route) { // Do something with wayfinding route }
Modifier and Type | Field and Description |
---|---|
static int |
CALIBRATION_EXCELLENT
Deprecated.
|
static int |
CALIBRATION_GOOD
Deprecated.
|
static int |
CALIBRATION_POOR
Deprecated.
|
static java.lang.String |
EXTRA_API_KEY
Extra attribute key to configure IndoorAtlas API key at run time.
|
static java.lang.String |
EXTRA_API_SECRET
Extra attribute key to configure IndoorAtlas API secret at run time.
|
static java.lang.String |
EXTRA_GEOFENCE_EVENT
Extra attribute key used when geofence events are delivered in an
Intent after
requesting geofence events with
requestGeofenceUpdates(PendingIntent) . |
static java.lang.String |
EXTRA_LOCATION
Extra attribute key used when location updates are delivered in an
Intent after
requesting location updates with
requestLocationUpdates(IALocationRequest, PendingIntent) . |
static java.lang.String |
EXTRA_WAYFINDING_EVENT |
static int |
STATUS_AVAILABLE
Location service running normally.
|
static int |
STATUS_CALIBRATION_CHANGED
Deprecated.
|
static int |
STATUS_LIMITED
Location service is running but with limited accuracy and functionality.
|
static int |
STATUS_OUT_OF_SERVICE
Location service is not available and the condition is not expected to resolve itself soon.
|
static int |
STATUS_TEMPORARILY_UNAVAILABLE
Location service temporarily unavailable due to the lack of network
connectivity.
|
Constructor and Description |
---|
IALocationManager() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addGeofences(IAGeofenceRequest request,
IAGeofenceListener listener) |
abstract void |
addGeofences(IAGeofenceRequest request,
IAGeofenceListener listener,
android.os.Looper looper)
Register for geofence event updates using
listener . |
abstract void |
addGeofences(IAGeofenceRequest request,
android.app.PendingIntent pendingIntent)
Request geofence events that are delivered to an application component specified by a
PendingIntent . |
static IALocationManager |
create(android.content.Context context)
Recommended constructor.
|
static IALocationManager |
create(android.content.Context context,
android.os.Bundle extras)
Creates a new instance of
IALocationManager . |
abstract void |
destroy()
Release all resources allocated by this class.
|
abstract IAExtraInfo |
getExtraInfo()
Returns additional information not vital for the functionality of the SDK.
|
abstract void |
lockFloor(int floorNumber)
Locks positioning to the specified floor level.
|
abstract void |
lockIndoors(boolean locked)
Engage or release indoor-only lock (a.k.a.
|
abstract boolean |
registerOrientationListener(IAOrientationRequest request,
IAOrientationListener listener)
Add a listener for device heading and orientation.
|
abstract boolean |
registerRegionListener(IARegion.Listener listener)
Add a listener for region events.
|
abstract void |
removeGeofences(java.util.List<java.lang.String> geofenceRequestIds)
Remove geofences from monitoring.
|
abstract boolean |
removeGeofenceUpdates(IAGeofenceListener listener)
Removes all updates for the specific
listener . |
abstract void |
removeGeofenceUpdates(android.app.PendingIntent pendingIntent)
Removes all updates for the specific
pendingIntent . |
abstract boolean |
removeLocationUpdates(IALocationListener listener)
Removes all updates for the specific
listener . |
abstract void |
removeLocationUpdates(android.app.PendingIntent pendingIntent)
Removes all updates for the specific
pendingIntent . |
abstract void |
removeWayfindingUpdates()
Removes wayfinding request.
|
abstract void |
removeWayfindingUpdates(android.app.PendingIntent pendingIntent)
Removes all updates for the specific
pendingIntent . |
abstract boolean |
requestLocationUpdates(IALocationRequest request,
IALocationListener listener) |
abstract boolean |
requestLocationUpdates(IALocationRequest request,
IALocationListener listener,
android.os.Looper looper)
Register for location updates using
request and listener . |
abstract void |
requestLocationUpdates(IALocationRequest request,
android.app.PendingIntent pendingIntent)
Request location and status updates updates that are delivered to an application
component specified by a
PendingIntent . |
abstract void |
requestWayfindingUpdates(IAWayfindingRequest request,
IAWayfindingListener listener)
Start requesting wayfinding updates.
|
abstract void |
requestWayfindingUpdates(IAWayfindingRequest request,
IAWayfindingListener listener,
android.os.Looper looper)
Start requesting wayfinding updates.
|
abstract void |
requestWayfindingUpdates(IAWayfindingRequest request,
android.app.PendingIntent pendingIntent)
Start requesting wayfinding updates.
|
abstract void |
setLocation(IALocation location)
Indicate current location to the positioning service.
|
abstract void |
unlockFloor()
Unlocks positioning from the locked floor.
|
abstract boolean |
unregisterOrientationListener(IAOrientationListener listener)
Remove orientation listener.
|
abstract boolean |
unregisterRegionListener(IARegion.Listener listener)
Remove region listener.
|
public static final int STATUS_OUT_OF_SERVICE
public static final int STATUS_TEMPORARILY_UNAVAILABLE
public static final int STATUS_AVAILABLE
public static final int STATUS_LIMITED
If running on Android 6.0 or above, make sure you have checked that at least
Manifest.permission.ACCESS_COARSE_LOCATION
has been granted.
@Deprecated public static final int STATUS_CALIBRATION_CHANGED
public static final java.lang.String EXTRA_API_KEY
create(Context, Bundle)
,
Constant Field Valuespublic static final java.lang.String EXTRA_API_SECRET
create(Context, Bundle)
,
Constant Field Valuespublic static final java.lang.String EXTRA_LOCATION
Intent
after
requesting location updates with
requestLocationUpdates(IALocationRequest, PendingIntent)
. The IALocation
is
stored as a byte array
. Please use IALocation.from(Intent)
to obtain the
IALocation
from the extras.public static final java.lang.String EXTRA_GEOFENCE_EVENT
Intent
after
requesting geofence events with
requestGeofenceUpdates(PendingIntent)
. The IAGeofenceEvent
is
stored as a byte array
. Please use IAGeofenceEvent.from(Intent)
to obtain the
IAGeofenceEvent
from the extras.public static final java.lang.String EXTRA_WAYFINDING_EVENT
@Deprecated public static final int CALIBRATION_POOR
@Deprecated public static final int CALIBRATION_GOOD
@Deprecated public static final int CALIBRATION_EXCELLENT
public static IALocationManager create(android.content.Context context)
IALocationManager
.context
- public static IALocationManager create(android.content.Context context, android.os.Bundle extras)
IALocationManager
.context
- extras
- extra arguments to service. See EXTRA_
constant fields for this class.public abstract void destroy()
create(Context)
with a corresponding call to this method. Calling any method after
calling destroy will throw an IllegalStateException
.public abstract boolean requestLocationUpdates(IALocationRequest request, IALocationListener listener, android.os.Looper looper)
request
and listener
.request
- contains parameters for location manager to choose how updates are delivered
to the listenerlistener
- a IALocationListener
whose
IALocationListener.onLocationChanged(IALocation)
will be invoked on
each update. Invocations are made in the main thread.looper
- a looper whose callback mechanism will be used to deliver callbacks or
null
to use the main thread.java.lang.IllegalArgumentException
- if request
is nulljava.lang.IllegalArgumentException
- if listener
is nulljava.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract boolean requestLocationUpdates(IALocationRequest request, IALocationListener listener)
public abstract void requestLocationUpdates(IALocationRequest request, android.app.PendingIntent pendingIntent)
Request location and status updates updates that are delivered to an application
component specified by a PendingIntent
. The location and status updates are in
the extras of the Intent
. Use IALocation.from(Intent)
to obtain the
location update.
Please see in the Android documentation how to configure the PendingIntent
.
Requesting location updates with this method leaves the IndoorAtlas location service
running in the background until removeLocationUpdates(PendingIntent)
is called
with a matching PendingIntent
. Alternatively, it can be killed manually by the
user or the entire process killed by Android to save resources.
request
- contains parameters for location manager to choose how updates are delivered
to the listenerpendingIntent
- specifies what component is notified with location updatesjava.lang.IllegalArgumentException
- if request
is nulljava.lang.IllegalArgumentException
- if pendingIntent
is nulljava.lang.IllegalStateException
- if called after destroy()
has been calledEXTRA_LOCATION
public abstract boolean removeLocationUpdates(IALocationListener listener)
listener
. After calling this method, updates
will no longer be delivered to the listener.listener
- a listener object that will no longer need location updatestrue
if listener
was registered and is now removed, otherwise
false
.java.lang.IllegalArgumentException
- if listener
is null
.java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract void removeLocationUpdates(android.app.PendingIntent pendingIntent)
pendingIntent
. After calling this method,
updates will no longer be delivered to the application component.pendingIntent
- a PendingIntent
that will no longer need location updates
false
.java.lang.IllegalArgumentException
- if pendingIntent
is null
.java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract void setLocation(IALocation location)
Indicate current location to the positioning service. This method can be used to set the explicit location (latitude, longitude, accuracy, floor level).
SeelockFloor(int)
and lockIndoors(boolean)
for restricting the positioning
to a certain floor level or disabling indoor-outdoor detection.
Explicit location is used as a hint in the system. This means that the inputted location is used only to determine the initial position. Example use cases:
1.) Set user location to WGS84 coordinates 60.01 latitude and 24.123 longitude with approximate accuracy of 5 meters and floor level 3.
IALocationManager.setLocation(new IALocation.Builder() .withLatitude(60.01) .withLongitude(24.123) .withAccuracy(5.0) .withFloorLevel(3) .build());Value of accuracy determines how strongly the horizontal position information is used. For example, if there is no good knowledge about horizontal position, but floor level is known, set accuracy to some large value (e.g. 75 meters).
2.) Set user location to WGS84 coordinates 60.01 latitude and 24.123 longitude with approximate accuracy of 5 meters and no information about floor level. In this case, IA floor detection is used to infer the floor level.
IALocationManager.setLocation(new IALocation.Builder() .withLatitude(60.01) .withLongitude(24.123) .withAccuracy(5.0) .build());
location
- location indicating current positionjava.lang.IllegalArgumentException
- is location
is nulljava.lang.IllegalStateException
- if called after destroy()
has been calledlockFloor(int)
,
lockIndoors(boolean)
public abstract boolean registerRegionListener(IARegion.Listener listener)
listener
- a IARegion.Listener
object to registerjava.lang.IllegalArgumentException
- if listener is null
java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract boolean unregisterRegionListener(IARegion.Listener listener)
listener
- a IARegion.Listener
object to be removedjava.lang.IllegalArgumentException
- if listener is null
java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract boolean registerOrientationListener(IAOrientationRequest request, IAOrientationListener listener)
requestLocationUpdates(IALocationRequest, IALocationListener)
. The sensitivity of
updates is configured using IAOrientationRequest
. It is possible to receive more
frequent updates than specified in the request if there are multiple listeners. The returned
orientation represents the current best estimate and can exhibit sudden jumps. The
orientation should be be filtered if used in e.g. virtual reality applications.request
- Request indicating sensitivitylistener
- a IAOrientationListener
object to registerjava.lang.IllegalArgumentException
- if listener is null
java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract boolean unregisterOrientationListener(IAOrientationListener listener)
listener
- a IAOrientationListener
object to be removedjava.lang.IllegalArgumentException
- if listener is null
java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract IAExtraInfo getExtraInfo()
java.lang.IllegalStateException
- if called after destroy()
has been called@Beta public abstract void removeGeofences(java.util.List<java.lang.String> geofenceRequestIds)
geofenceRequestIds
- List of geofence IDs we no longer wish to monitor.java.lang.IllegalStateException
- if called after destroy()
has been called@Beta public abstract void addGeofences(IAGeofenceRequest request, IAGeofenceListener listener, android.os.Looper looper)
listener
.listener
- a IAGeofenceListener
whose
IAGeofenceListener.onGeofencesTriggered(IAGeofenceEvent)
will be
invoked on each update. Invocations are made in the main thread.java.lang.IllegalArgumentException
- if listener
is nulljava.lang.IllegalStateException
- if called after destroy()
has been called@Beta public abstract void addGeofences(IAGeofenceRequest request, IAGeofenceListener listener)
@Beta public abstract boolean removeGeofenceUpdates(IAGeofenceListener listener)
listener
. After calling this method, updates
will no longer be delivered to the listener.listener
- a listener object that will no longer need location updatestrue
if listener
was registered and is now removed, otherwise
false
.java.lang.IllegalArgumentException
- if listener
is null
.java.lang.IllegalStateException
- if called after destroy()
has been called@Beta public abstract void addGeofences(IAGeofenceRequest request, android.app.PendingIntent pendingIntent)
Request geofence events that are delivered to an application component specified by a
PendingIntent
. The location and status updates are in the extras of the
Intent
. Use IALocation.from(Intent)
to obtain the location update.
Please see in the Android documentation how to configure the PendingIntent
.
pendingIntent
- specifies what component is notified with geofence eventsjava.lang.IllegalArgumentException
- if pendingIntent
is nulljava.lang.IllegalStateException
- if called after destroy()
has been calledEXTRA_GEOFENCE_EVENT
@Beta public abstract void removeGeofenceUpdates(android.app.PendingIntent pendingIntent)
pendingIntent
. After calling this method,
geofence events will no longer be delivered to the application component.pendingIntent
- a PendingIntent
that will no longer need geofence events.java.lang.IllegalArgumentException
- if pendingIntent
is null
.java.lang.IllegalStateException
- if called after destroy()
has been calledpublic abstract void lockFloor(int floorNumber)
lockIndoors(boolean)
has no effect on floor level lock.floorNumber
- Floor level where the positioning is restrictedunlockFloor()
,
lockIndoors(boolean)
public abstract void unlockFloor()
lockFloor(int)
has not been called before
this is a no-op.public abstract void lockIndoors(boolean locked)
lockFloor(int)
also enables the indoor-only lock (and it then cannot
be disabled with this method as long as the floor level is locked)locked
- boolean value indicating whether to enable or disable the indoor-only lock.lockFloor(int)
public abstract void requestWayfindingUpdates(IAWayfindingRequest request, IAWayfindingListener listener, android.os.Looper looper)
request
- Wayfinding requestlistener
- a IAWayfindingListener
object to registerlooper
- a looper who's callback mechanism will be used to deliver callbackspublic abstract void requestWayfindingUpdates(IAWayfindingRequest request, IAWayfindingListener listener)
request
- Wayfinding requestlistener
- a IAWayfindingListener
object to registerpublic abstract void requestWayfindingUpdates(IAWayfindingRequest request, android.app.PendingIntent pendingIntent)
request
- Wayfinding requestpendingIntent
- a IAWayfindingListener
object to register
Request wayfinding updates that are delivered to an application component specified by a
PendingIntent
. The location and status updates are in the extras of the
Intent
. Use IARoute.from(Intent)
to obtain the update.
Please see the Android documentation how to configure the PendingIntent
.
public abstract void removeWayfindingUpdates()
public abstract void removeWayfindingUpdates(android.app.PendingIntent pendingIntent)
pendingIntent
. After call to this method,
wayfinding events will no longer be delivered to the application component.pendingIntent
- a PendingIntent
that will no longer need wayfinding events.java.lang.IllegalArgumentException
- if pendingIntent
is null
.java.lang.IllegalStateException
- if called after destroy()
has been called