Tip: Indoor-outdoor transitions are demonstrated in the Google Maps Overlay code example

Accurate indoor-outdoor detection requires GPS. IndoorAtlas SDK manages the platform location scanning, but you need to provide the necessary permissions:


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


Also remember to query for the user’s permission as described in the SDK setup section.



Like automatic floor detection, Indoor-outdoor transitions are signaled with the IARegion events.


private IARegion.Listener mRegionListener = new IARegion.Listener() {
    // when null, we are not on any mapped area
    // this information can be used for indoor-outdoor detection
    IARegion mCurrentFloorPlan = null;

    @Override
    public void onEnterRegion(IARegion region) {
        if (region.getType() == IARegion.TYPE_FLOOR_PLAN) {
            // triggered when entering the mapped area of the given floor plan
            Log.d(TAG, "Entered " + region.getName());
            Log.d(TAG, "floor plan ID: " + region.getId());
            mCurrentFloorPlan = region;
        }
        else if (region.getType() == IARegion.TYPE_VENUE) {
            // triggered when near a new location
            Log.d(TAG, "Location changed to " + region.getId());
        }
    }

    @Override
    public void onExitRegion(IARegion region) {
        // leaving a previously entered region
        if (region.getType() == IARegion.TYPE_FLOOR_PLAN) {
            mCurrentFloorPlan = null;
            // notice that a change of floor plan (e.g., floor change)
            // is signaled by an exit-enter pair so ending up here
            // does not yet mean that the device is outside any mapped area
        }
    }
};


Location and floor plan regions


In the above code snippet, there are two types of region entry events. The TYPE_FLOOR_PLAN entry events are triggered when the user actually enters the mapped area of the floor plan. In almost all cases, this corresponds to physically entering the building. The TYPE_VENUE events are emitted a lot earlier, between 100 and 200 meters away from the location (a.k.a. venue). This is meant as a heads-up to enable pre-loading of data. The venue entry events are also useful in the case when one wishes to disable automatic indoor-outdoor detection.


Floor plan and venue regions




LockIndoors aka Disabling indoor-outdoor detection


In some venues there may be areas where indoor-outdoor detection falsely detects outdoor when the user is indoors. If you prefer that the positioning is accurate indoors (at the cost of not detecting that the user goes outdoor), you can disable indoor-outdoor detection. This is done with lockIndoors(true);

If lockIndoors is enabled when the user approaches a venue, the correct venue is still automatically detected automatically. After starting indoor positioning, GPS is no longer scanned.

Note that lockFloor and lockIndoors can be used together but it is redundant in most cases: Locking positioning to specific floor also implicitly locks positioning indoors.


// Lock positioning indoors (i.e., enable indoor-only mode)
IALocationManager.lockIndoors(true);

// Unlock positioning indoors (disable indoor-only mode)
IALocationManager.lockIndoors(false);