To run IndoorAtlas SDK on an Android device, you need

  • SDK minimum API level 21 (Lollipop)
  • Physical Android device (emulator is not supported) with Wi-Fi connectivity. 
  • Accelerometer, Gyroscope and Magnetometer are preferred.


Note that there are several complete examples in the IndoorAtlas Android Examples


Add SDK dependency


For new projects built with Gradle, we recommend using AAR as it is easier to integrate. AAR contains both Java classes and AndroidManifest.xml template which gets merged into your application’s AndroidManifest.xml during build process.

Add this to your build.gradle file.

NOTE: Check the latest SDK version from here and update below!

Or start with our complete SDK examples from Github, they always include the latest SDK version.


dependencies {
  compile 'com.indooratlas.android:indooratlas-android-sdk:3.4.12@aar'
}
repositories{
  maven {
    url "https://dl.cloudsmith.io/public/indooratlas/mvn-public/maven/"
  }
}



We recommend automating dependency management of integrated SDKs such as ours using Gradle as described above. However, if you can not do this, you have an option of manually adding the SDK to your projects, by following the manual installation guide.





Add credentials to the Android manifest file


Every application which uses IndoorAtlas service needs a unique ApiKey and Secret strings, which you can manage with IndoorAtlas Applications. See here for further information on API keys.

Add your app credentials as meta-data attributes to AndroidManifest.xml


<application>
  <meta-data
    android:name="com.indooratlas.android.sdk.API_KEY"
    android:value="api-key-here"/>
  <meta-data
    android:name="com.indooratlas.android.sdk.API_SECRET"
    android:value="api-secret-here"/>
</application>



Getting user’s permission (Android 6+)


Special note for Android 12


In order to use IndoorAtlas SDK with Android targetSdkVersion 31, you need to declare the following permission in the app AndroidManifest.xml: <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

The BLUETOOTH_SCAN permission also needs to be requested at runtime along with ACCESS_FINE_LOCATION. 


Do NOT declare or request the BLUETOOTH_SCAN permission if still using targetSdkVersion 30 or lower. For more info see https://developer.android.com/guide/topics/connectivity/bluetooth/permissions 


Requesting permissions


Before you can use IndoorAtlas location framework on Android versions 6 and above, your application will need to get user’s permission for coarse location and Wi-Fi status. You can accomplish this in your application’s main Activity:


private final int CODE_PERMISSIONS = //...

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  String[] neededPermissions = {
    Manifest.permission.ACCESS_COARSE_LOCATION,
    Manifest.permission.ACCESS_FINE_LOCATION
  };
  ActivityCompat.requestPermissions( this, neededPermissions, CODE_PERMISSIONS );
}

//...

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  super.onRequestPermissionsResult(requestCode, permissions, grantResults);

  //Handle if any of the permissions are denied, in grantResults
}


For above code to work you need to add correct version of Google's support library to your dependencies file. Right version depends on target SDK version you are building.

dependencies {
    implementation 'com.android.support:support-compat:27.0.0'
}



Special setup for supporting only high-performance device models


The SDK uses three hardware sensors, BLE beacons, Wi-Fi and Visual inertial odometry (in AR mode) when available on the device. It will function also without some of these sensors to a limited degree, but if your app requires full performance and you’re willing to limit its device compatibility, declaring these in the manifest restricts the devices on which the SDK can be installed from Google Play. You can do this by adding the following declarations to your AndroidManifest.xml before application -element.


<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" /> 
<uses-feature android:name="android.hardware.sensor.compass"  android:required="true" />
<uses-feature android:name="android.hardware.sensor.gyroscope"  android:required="true" />
<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />