Prerequisites

To develop applications with Xamarin, you first need to setup the Visual Studio for Xamarin development environment. I already had an existing Android environment so if you don't, you may need to install Android SDK before you can build your Android application.


Get Visual Studio for Xamarin


Download and install the Visual Studio tools for Xamarin. When the Visual Studio is installed you should see something like this.


Create the Library Binding

Before you can use our SDK from your Xamarin application, you need to create, what Xamarin calls a Binding Library. Once that library is created, you can consume it from a client application.


The tutorial below is based on this one: https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar


Create new Binding Project


Choose "New Project..." and choose "Android Bindings Library (Xamarin)" as the new project type. 


 


Select the location of the new project and give it a descriptive name.

 


Download IndoorAtlas Android SDK


At the time of writing this, we don't know if there is a more elegant way of referencing an AAR file to bind, so the AAR file needs to be downloaded locally. The officially released IndoorAtlas Android SDK libraries are distributed via Bintray so open this link and download the latest version (or older version). You can download the ZIP, which contains all distribution files, but the AAR file is enough for this purpose.



Add IndoorAtlas SDK to Your Project


In the Visual Studio, go under Jars folder and choose Add Files....


Browse into the location where you downloaded IndoorAtlas Android SDK AAR file and select it. The Visual Studio may ask if you wish to copy the file into the project or reference it. I chose to copy under the project. This is how your project should look now. Also, double check that the Build action is set to LibraryProjectZip.


Configure Target Framework


Visual Studio needs to know the Android framework version the IndoorAtlas SDK AAR was build against. IndoorAtlas SDK 3.2.1 for Android was built against API 26, Marshmallow. Thus, we select Android 8.0 here.

Open Project Options dialog.



Select Android 8.0




Note that the IDE shows an asterisk after the selected version. This means the version was not yet installed. In this case, open the Android SDK manager and install the version. Note that for some reason I had to re-create the bindings-project afresh to make it compile successfully after installing the new Android version.


Build the Binding Project


Right click the project and choose Build



If you chose an Android framework which was not previously installed, Visual Studio will prompt you to download it. The build may generate several warnings. Most of these are related to obfuscated code and can be ignored for now. When the build succeeds, you should find the generated DLL in the bin/Debug directory under your binding project.






Build the Client Application


Now that we have create the binding for IndoorAtlas Android SDK, we can consume that from a client application.


Create a New Android Application


We'll add a new project under the same solution...




... and choose Android App as the project type. 



Give it a descriptive name and hit Create.




Reference Binding Library


We need to tell Visual Studio that we want to use the IndoorAtlas Xamarin Binding Library we created in first step. Edit the project references.




And choose our binding library under the Projects tab.



Note, if you create it as a separate project, you can select the IndoorAtlas bindings DLL as a reference:




You can now double click the imported binding library to verify that all important IndoorAtlas classes are available.


Setup Application for Indoor Positioning

Since the wrapping that Visual Studio produces in C# is very very close to our Java library for native Android, you can follow our standard documentation on how to setup IndoorAtlas' indoor positioning for Android


In short those steps are:


I also added two TextView widgets, one to display the status of IndoorAtlas positioning and another to display the currently detected location. Now my MainActivity.cs looks like this:



Run the App


After deploying the app into a real Android device and starting it the UI should look like this. The first TextView displays the current status (see actual API documentation to translate the codes) and the second TextView display the currently detected location as a string.



Same application in a short video for non-believers.