Android SDK setup

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.

dependencies {
	compile 'com.indooratlas.android:indooratlas-android-sdk:{{site.versions.androidSdkVersion}}@aar'
}
repositories{
	maven {
		url "http://indooratlas-ltd.bintray.com/mvn-public"
	}
}

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.

Declare sensors

Basic setup

The SDK uses three hardware sensors and Wi-Fi when available. 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" />

Enabling Beacon support

Beacons are not strictly necessary for positioning to work but enabling this feature is recommended for optimal performance.

During runtime, SDK checks if permissions are granted and that Bluetooth service is enabled by the user. Support for beacons is silently ignored if these conditions are not met.

As default, SDK does not add required permissions to scan beacons. To enable support, add the following permissions to your applications AndroidManifest.xml:

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

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+)

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.CHANGE_WIFI_STATE,
		Manifest.permission.ACCESS_WIFI_STATE,
		Manifest.permission.ACCESS_COARSE_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
}