Class IALocationManager
- java.lang.Object
-
- com.indooratlas.android.sdk.IALocationManager
-
public abstract class IALocationManager extends 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
Log
using log tagIASDK
.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 List<double[]> 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 }
Monitor wayfinding route changes:protected void onCreate(Bundle bundle) { super.onCreate(bundle) mLocationManager = IALocationManager.create(context); mLocationManager.requestLocationUpdates(IALocationRequest.create(), this); IAWayfindingRequest request = new IAWayfindingRequest.Builder() .withLatitude(60.1692229) .withLongitude(24.9326988) .withFloor(1) .build(); mLocationManager.requestWayfindingUpdates(request, this); } public void onWayfindingUpdate(IARoute route) { // Do something with wayfinding route }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IALocationManager.Consumer<T>
-
Field Summary
Fields Modifier and Type Field Description static String
EXTRA_API_KEY
Extra attribute key to configure IndoorAtlas API key at run time.static String
EXTRA_API_SECRET
Extra attribute key to configure IndoorAtlas API secret at run time.static String
EXTRA_GEOFENCE_EVENT
Extra attribute key used when geofence events are delivered in anIntent
after requesting geofence events withaddGeofences(IAGeofenceRequest,PendingIntent)
.static String
EXTRA_LOCATION
Extra attribute key used when location updates are delivered in anIntent
after requesting location updates withrequestLocationUpdates(IALocationRequest, PendingIntent)
.static String
EXTRA_WAYFINDING_EVENT
static int
STATUS_AVAILABLE
Location service running normally.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 Summary
Constructors Constructor Description IALocationManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addGeofences(IAGeofenceRequest request, PendingIntent pendingIntent)
Request geofence events that are delivered to an application component specified by aPendingIntent
.abstract void
addGeofences(IAGeofenceRequest request, IAGeofenceListener listener)
abstract void
addGeofences(IAGeofenceRequest request, IAGeofenceListener listener, Looper looper)
Register for geofence event updates usinglistener
.static IALocationManager
create(Context context)
Recommended constructor.static IALocationManager
create(Context context, Bundle extras)
Creates a new instance ofIALocationManager
.abstract void
destroy()
Release all resources allocated by this class.abstract void
finishRecordingBinaryLog(IALocationManager.Consumer<byte[]> consumer)
Finish recording binary log data.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(List<String> geofenceRequestIds)
Remove geofences from monitoring.abstract void
removeGeofenceUpdates(PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
.abstract boolean
removeGeofenceUpdates(IAGeofenceListener listener)
Removes all updates for the specificlistener
.abstract void
removeLocationUpdates(PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
.abstract boolean
removeLocationUpdates(IALocationListener listener)
Removes all updates for the specificlistener
.abstract void
removeRadioScanUpdates()
Stop listening to radio scans.abstract void
removeWayfindingUpdates()
Removes wayfinding request.abstract void
removeWayfindingUpdates(PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
.abstract IAARSession
requestArUpdates()
Start AR fusion updates.abstract void
requestLocationUpdates(IALocationRequest request, PendingIntent pendingIntent)
Request location and status updates updates that are delivered to an application component specified by aPendingIntent
.abstract boolean
requestLocationUpdates(IALocationRequest request, IALocationListener listener)
abstract boolean
requestLocationUpdates(IALocationRequest request, IALocationListener listener, Looper looper)
Register for location updates usingrequest
andlistener
.abstract void
requestRadioScanUpdates(IARadioScanRequest request, IARadioScanListener listener)
Request radio scan updates.abstract void
requestRadioScanUpdates(IARadioScanRequest request, IARadioScanListener listener, Looper looper)
Request radio scan updates.abstract void
requestWayfindingRoute(IALatLngFloorCompatible from, IALatLngFloorCompatible to, IAWayfindingListener listener)
Request a single-shot wayfinding route.abstract void
requestWayfindingUpdates(IALatLngFloorCompatible to, PendingIntent pendingIntent)
Start requesting wayfinding updates.abstract void
requestWayfindingUpdates(IALatLngFloorCompatible to, IAWayfindingListener listener)
Start requesting wayfinding updates.abstract void
requestWayfindingUpdates(IALatLngFloorCompatible to, IAWayfindingListener listener, Looper looper)
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.
-
-
-
Field Detail
-
STATUS_OUT_OF_SERVICE
public static final int STATUS_OUT_OF_SERVICE
Location service is not available and the condition is not expected to resolve itself soon.- See Also:
- Constant Field Values
-
STATUS_TEMPORARILY_UNAVAILABLE
public static final int STATUS_TEMPORARILY_UNAVAILABLE
Location service temporarily unavailable due to the lack of network connectivity. This mostly happens in the beginning of a positioning session when the SDK need to authenticate itself in the IndoorAtlas cloud and download map data, if it has not been cached yet.- See Also:
- Constant Field Values
-
STATUS_AVAILABLE
public static final int STATUS_AVAILABLE
Location service running normally.- See Also:
- Constant Field Values
-
STATUS_LIMITED
public static final int STATUS_LIMITED
Location service is running but with limited accuracy and functionality. This may be, e.g., if WiFi information is not available because the user has disabled WiFi scanning or the relevant permissions have not been granted (Android 6.0+).If running on Android 6.0 or above, make sure you have checked that at least
Manifest.permission.ACCESS_COARSE_LOCATION
has been granted.- See Also:
- Constant Field Values
-
EXTRA_API_KEY
public static final String EXTRA_API_KEY
Extra attribute key to configure IndoorAtlas API key at run time. This is an optional way of configuring API credentials. If key and secret are not defined, SDK will try to read this information from meta-data attributes in AndroidManifest.xml. See the Getting Started guide for more info.- See Also:
create(Context, Bundle)
, Constant Field Values
-
EXTRA_API_SECRET
public static final String EXTRA_API_SECRET
Extra attribute key to configure IndoorAtlas API secret at run time. This is an optional way of configuring API credentials. If key and secret are not defined, SDK will try to read this information from meta-data attributes in AndroidManifest.xml. See the Getting Started guide for more info.- See Also:
create(Context, Bundle)
, Constant Field Values
-
EXTRA_LOCATION
public static final String EXTRA_LOCATION
Extra attribute key used when location updates are delivered in anIntent
after requesting location updates withrequestLocationUpdates(IALocationRequest, PendingIntent)
. TheIALocation
is stored as abyte array
. Please useIALocation.from(Intent)
to obtain theIALocation
from the extras.- See Also:
- Constant Field Values
-
EXTRA_GEOFENCE_EVENT
public static final String EXTRA_GEOFENCE_EVENT
Extra attribute key used when geofence events are delivered in anIntent
after requesting geofence events withaddGeofences(IAGeofenceRequest,PendingIntent)
. TheIAGeofenceEvent
is stored as abyte array
. Please useIAGeofenceEvent.from(Intent)
to obtain theIAGeofenceEvent
from the extras.- See Also:
- Constant Field Values
-
EXTRA_WAYFINDING_EVENT
public static final String EXTRA_WAYFINDING_EVENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static IALocationManager create(@NonNull Context context)
Recommended constructor. Creates a new instance ofIALocationManager
.- Parameters:
context
-
-
create
public static IALocationManager create(@NonNull Context context, @Nullable Bundle extras)
Creates a new instance ofIALocationManager
.- Parameters:
context
-extras
- extra arguments to service. SeeEXTRA_
constant fields for this class.
-
destroy
public abstract void destroy()
Release all resources allocated by this class. Remember to pair a call tocreate(Context)
with a corresponding call to this method. Calling any method after calling destroy will throw anIllegalStateException
.
-
requestLocationUpdates
public abstract boolean requestLocationUpdates(@NonNull IALocationRequest request, @NonNull IALocationListener listener, Looper looper)
Register for location updates usingrequest
andlistener
.- Parameters:
request
- contains parameters for location manager to choose how updates are delivered to the listenerlistener
- aIALocationListener
whoseIALocationListener.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 ornull
to use the main thread.- Returns:
- true if the listener was successfully registered (or already registered), false if registering failed.
- Throws:
IllegalArgumentException
- ifrequest
is nullIllegalArgumentException
- iflistener
is nullIllegalStateException
- if called afterdestroy()
has been called
-
requestLocationUpdates
public abstract boolean requestLocationUpdates(@NonNull IALocationRequest request, @NonNull IALocationListener listener)
-
requestLocationUpdates
public abstract void requestLocationUpdates(@NonNull IALocationRequest request, @NonNull 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 theIntent
. UseIALocation.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 matchingPendingIntent
. Alternatively, it can be killed manually by the user or the entire process killed by Android to save resources.- Parameters:
request
- contains parameters for location manager to choose how updates are delivered to the listenerpendingIntent
- specifies what component is notified with location updates- Throws:
IllegalArgumentException
- ifrequest
is nullIllegalArgumentException
- ifpendingIntent
is nullIllegalStateException
- if called afterdestroy()
has been called- See Also:
EXTRA_LOCATION
-
removeLocationUpdates
public abstract boolean removeLocationUpdates(@NonNull IALocationListener listener)
Removes all updates for the specificlistener
. After calling this method, updates will no longer be delivered to the listener.- Parameters:
listener
- a listener object that will no longer need location updates- Returns:
true
iflistener
was registered and is now removed, otherwisefalse
.- Throws:
IllegalArgumentException
- iflistener
isnull
.IllegalStateException
- if called afterdestroy()
has been called
-
removeLocationUpdates
public abstract void removeLocationUpdates(@NonNull PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
. After calling this method, updates will no longer be delivered to the application component.- Parameters:
pendingIntent
- aPendingIntent
that will no longer need location updatesfalse
.- Throws:
IllegalArgumentException
- ifpendingIntent
isnull
.IllegalStateException
- if called afterdestroy()
has been called
-
setLocation
public abstract void setLocation(@NonNull 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)
for restricting the positioning to a certain floor level.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());
- Parameters:
location
- location indicating current position- Throws:
IllegalArgumentException
- islocation
is nullIllegalStateException
- if called afterdestroy()
has been called- See Also:
lockFloor(int)
,lockIndoors(boolean)
-
registerRegionListener
public abstract boolean registerRegionListener(@NonNull IARegion.Listener listener)
Add a listener for region events.- Parameters:
listener
- aIARegion.Listener
object to register- Returns:
- true if listener was successfully registered, false if already registered.
- Throws:
IllegalArgumentException
- if listener isnull
IllegalStateException
- if called afterdestroy()
has been called
-
unregisterRegionListener
public abstract boolean unregisterRegionListener(@NonNull IARegion.Listener listener)
Remove region listener.- Parameters:
listener
- aIARegion.Listener
object to be removed- Returns:
- true if listener was successfully unregistered, false if was not found.
- Throws:
IllegalArgumentException
- if listener isnull
IllegalStateException
- if called afterdestroy()
has been called
-
registerOrientationListener
public abstract boolean registerOrientationListener(@NonNull IAOrientationRequest request, @NonNull IAOrientationListener listener)
Add a listener for device heading and orientation. Heading and orientation updates are not given unless positioning is started withrequestLocationUpdates(IALocationRequest, IALocationListener)
. The sensitivity of updates is configured usingIAOrientationRequest
. 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.- Parameters:
request
- Request indicating sensitivitylistener
- aIAOrientationListener
object to register- Returns:
- true if listener was successfully registered, false if already registered.
- Throws:
IllegalArgumentException
- if listener isnull
IllegalStateException
- if called afterdestroy()
has been called
-
unregisterOrientationListener
public abstract boolean unregisterOrientationListener(@NonNull IAOrientationListener listener)
Remove orientation listener.- Parameters:
listener
- aIAOrientationListener
object to be removed- Returns:
- true if listener was successfully unregistered, false if it was not found.
- Throws:
IllegalArgumentException
- if listener isnull
IllegalStateException
- if called afterdestroy()
has been called
-
getExtraInfo
@NonNull public abstract IAExtraInfo getExtraInfo()
Returns additional information not vital for the functionality of the SDK.- Returns:
- Extraneous information.
- Throws:
IllegalStateException
- if called afterdestroy()
has been called
-
removeGeofences
public abstract void removeGeofences(List<String> geofenceRequestIds)
Remove geofences from monitoring.- Parameters:
geofenceRequestIds
- List of geofence IDs we no longer wish to monitor.- Throws:
IllegalStateException
- if called afterdestroy()
has been called
-
addGeofences
public abstract void addGeofences(@NonNull IAGeofenceRequest request, @NonNull IAGeofenceListener listener, Looper looper)
Register for geofence event updates usinglistener
.- Parameters:
listener
- aIAGeofenceListener
whoseIAGeofenceListener.onGeofencesTriggered(IAGeofenceEvent)
will be invoked on each update. Invocations are made in the main thread.- Throws:
IllegalArgumentException
- iflistener
is nullIllegalStateException
- if called afterdestroy()
has been called
-
addGeofences
public abstract void addGeofences(@NonNull IAGeofenceRequest request, @NonNull IAGeofenceListener listener)
-
removeGeofenceUpdates
public abstract boolean removeGeofenceUpdates(@NonNull IAGeofenceListener listener)
Removes all updates for the specificlistener
. After calling this method, updates will no longer be delivered to the listener.- Parameters:
listener
- a listener object that will no longer need location updates- Returns:
true
iflistener
was registered and is now removed, otherwisefalse
.- Throws:
IllegalArgumentException
- iflistener
isnull
.IllegalStateException
- if called afterdestroy()
has been called
-
addGeofences
public abstract void addGeofences(@NonNull IAGeofenceRequest request, @NonNull PendingIntent pendingIntent)
Request geofence events that are delivered to an application component specified by a
PendingIntent
. The geofence event is in the extras of theIntent
. UseIAGeofenceEvent.from(Intent)
to obtain the geofence event.Please see in the Android documentation how to configure the
PendingIntent
.- Parameters:
pendingIntent
- specifies what component is notified with geofence events- Throws:
IllegalArgumentException
- ifpendingIntent
is nullIllegalStateException
- if called afterdestroy()
has been called- See Also:
EXTRA_GEOFENCE_EVENT
-
removeGeofenceUpdates
public abstract void removeGeofenceUpdates(@NonNull PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
. After calling this method, geofence events will no longer be delivered to the application component.- Parameters:
pendingIntent
- aPendingIntent
that will no longer need geofence events.- Throws:
IllegalArgumentException
- ifpendingIntent
isnull
.IllegalStateException
- if called afterdestroy()
has been called
-
lockFloor
public abstract void lockFloor(int floorNumber)
Locks positioning to the specified floor level. Locked floor level also enables indoor-only mode, but not vice versa, i.e.,lockIndoors(boolean)
has no effect on floor level lock.- Parameters:
floorNumber
- Floor level where the positioning is restricted- See Also:
unlockFloor()
,lockIndoors(boolean)
-
unlockFloor
public abstract void unlockFloor()
Unlocks positioning from the locked floor. IflockFloor(int)
has not been called before this is a no-op.
-
lockIndoors
public abstract void lockIndoors(boolean locked)
Engage or release indoor-only lock (a.k.a. indoor-only mode). If locked, automatic indoor-outdoor detection is disabled. Indoor-only lock is enabled by default. Notice thatlockFloor(int)
also enables the indoor-only lock (and it then cannot be disabled with this method as long as the floor level is locked)- Parameters:
locked
- boolean value indicating whether to enable or disable the indoor-only lock.- See Also:
lockFloor(int)
-
requestWayfindingUpdates
public abstract void requestWayfindingUpdates(@NonNull IALatLngFloorCompatible to, @NonNull IAWayfindingListener listener, Looper looper)
Start requesting wayfinding updates.- Parameters:
to
- Wayfinding destinationlistener
- aIAWayfindingListener
object to registerlooper
- a looper who's callback mechanism will be used to deliver callbacks
-
requestWayfindingUpdates
public abstract void requestWayfindingUpdates(@NonNull IALatLngFloorCompatible to, @NonNull IAWayfindingListener listener)
Start requesting wayfinding updates.- Parameters:
to
- Wayfinding destinationlistener
- aIAWayfindingListener
object to register
-
requestWayfindingUpdates
public abstract void requestWayfindingUpdates(@NonNull IALatLngFloorCompatible to, @NonNull PendingIntent pendingIntent)
Start requesting wayfinding updates.- Parameters:
to
- Wayfinding destinationpendingIntent
- aIAWayfindingListener
object to register Request wayfinding updates that are delivered to an application component specified by aPendingIntent
. The wayfinding update is in the extras of theIntent
. UseIARoute.from(Intent)
to obtain the update.Please see the Android documentation how to configure the
PendingIntent
.
-
removeWayfindingUpdates
public abstract void removeWayfindingUpdates()
Removes wayfinding request.
-
removeWayfindingUpdates
public abstract void removeWayfindingUpdates(@NonNull PendingIntent pendingIntent)
Removes all updates for the specificpendingIntent
. After call to this method, wayfinding events will no longer be delivered to the application component.- Parameters:
pendingIntent
- aPendingIntent
that will no longer need wayfinding events.- Throws:
IllegalArgumentException
- ifpendingIntent
isnull
.IllegalStateException
- if called afterdestroy()
has been called
-
requestWayfindingRoute
public abstract void requestWayfindingRoute(@NonNull IALatLngFloorCompatible from, @NonNull IALatLngFloorCompatible to, @NonNull IAWayfindingListener listener)
Request a single-shot wayfinding route.- Parameters:
from
- Wayfinding starting locationto
- Wayfinding destinationlistener
- aIAWayfindingListener
listener to provide route to
-
requestArUpdates
@Restricted @Beta public abstract IAARSession requestArUpdates()
Start AR fusion updates. NOTE! To enable AR features, please contact IndoorAtlas sales.- Returns:
- AR API object. Should be cleaned up by calling its destroy method when it is no longer used
-
requestRadioScanUpdates
@Restricted @Beta public abstract void requestRadioScanUpdates(@NonNull IARadioScanRequest request, @NonNull IARadioScanListener listener)
Request radio scan updates. Whenever IA SDK internally scans beacons or wifis, you can register a listener via with to receive the scan results. Only one listener can be active at same time and a new request will override any old one. The callback is delivered via main thread by default. NOTE! To enable the callback, please contact IndoorAtlas support.- Parameters:
request
- configuration for which callbacks to enablelistener
- via with to provide scan callbacks
-
requestRadioScanUpdates
@Restricted @Beta public abstract void requestRadioScanUpdates(@NonNull IARadioScanRequest request, @NonNull IARadioScanListener listener, Looper looper)
Request radio scan updates. Whenever IA SDK internally scans beacons or wifis, you can register a listener via with to receive the scan results. Only one listener can be active at same time and a new request will override any old one. NOTE! To enable the callback, please contact IndoorAtlas support.- Parameters:
request
- configuration for which callbacks to enablelistener
- via with to provide scan callbackslooper
- a looper via with to deliver callbacks ornull
to use the main thread.
-
removeRadioScanUpdates
@Restricted @Beta public abstract void removeRadioScanUpdates()
Stop listening to radio scans.
-
finishRecordingBinaryLog
@Beta public abstract void finishRecordingBinaryLog(IALocationManager.Consumer<byte[]> consumer)
Finish recording binary log data. This method is meant for enterprise users to share debug data with IndoorAtlas support. If your API key already has data storage enabled, there is no need to use this method.
-
-