This is a sample Android application built with Situm Wayfinding Module. Situm Wayfinding Module has been designed to create indoor location applications in the simplest way. It has been built in the top of the Situm SDK and its functionalities has been widely tested. If you are interested in building applications using the Situm SDK, please refer to Situm Android SDK Sample app.
With the samples app you will be able to:
- Load a Situm Map with all the buildings of your account and start the positioning for a selected building, using the
SitumMapView
andSitumMap
objects. - Set listeners to receive notifications about user location, buildings, POIs and routes.
- Get more control of the map loading using the underlying
SitumMapsLibrary
object. - Delegate
onBackPressed()
events for convenience.
- Step 1: Configure your Android project
- Step 2: Set your credentials
- Step 3: Configure Third Party Dependencies
- SitumMapView
- Install listeners using SitumMap
- Load the map using SitumMapsLibrary
- Delegate onBackPressed events
- Set your own theme in the UI
- Remove the
situm_search_view
feature - Customize location, navigation and directions requests
Situm SDK is a set of utilities that allow any developer to build location based apps using Situm's indoor positioning system. Among many other capabilities, apps developed with Situm SDK will be able to:
- Obtain information related to buildings where Situm's positioning system is already configured: floor plans, points of interest, geotriggered events, etc.
- Retrieve the location of the smartphone inside these buildings (position, orientation, and floor where the smartphone is).
- Compute a route from a point A (e.g. where the smartphone is) to a point B (e.g. any point of interest within the building).
- Trigger notifications when the user enters a certain area.
In this tutorial, we will guide you step by step to set up your first Android application using the Situm Wayfinding Module, which has been built in the top of the Situm SDK to extremely easy the development of indoor positioning Android applications.
Before starting to write code, we recommend you to set up an account in our Dashboard (https://dashboard.situm.es), retrieve your API KEY and configure your first building.
- Go to the sign in form and enter your username and password to sign in.
- Go to the account section and on the bottom, click on "generate one" to generate your API KEY.
- Go to the buildings section and create your first building.
- Download Situm Mapping Tool Android application. With this application you will be able to configure and test Situm's indoor positioning system in your buildings.
Perfect! Now you are ready to develop your first indoor positioning application.
First of all, you must configure Situm SDK and Situm Wayfinding Module in your Android project. This has been already done for you in the sample application, but nonetheless we will walk you through the process.
- Add our maven repository to the project build.gradle:
allprojects {
repositories {
maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}
- Now add the Situm Wayfinding Module dependency into the dependencies section of the app build.gradle.
implementation ('es.situm:situm-wayfinding:0.2.0-alpha@aar') {
transitive = true
}
It's important to add the transitive = true
property to download the inherited dependencies.
- Set compatibility with Java 8 in your app build.gradle file:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
- Finally, add multidex compatibility to your app build.gradle:
android {
defaultConfig {
...
minSdkVersion 16
targetSdkVersion Y
multiDexEnabled true
}
...
}
Please remember that if your minSdkVersion
is set to 20 or lower, you must use the multidex support library as follows:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
There are two ways to set the credentials, in the AndroidManifest.xml
file or programmatically.
You can set the credentials (user and API key) in the application
element of your AndroidManifest.xml
file adding the next meta-data
fields:
<meta-data
android:name="es.situm.maps.API_USER"
android:value="YOUR_API_USER" />
<meta-data
android:name="es.situm.maps.API_KEY"
android:value="YOUR_API_KEY" />
When using the SitumMapsLibrary object
, you can set the the user and API key with:
librarySettings.setApiKey(USER, API_KEY);
Or with user and password:
librarySettings.setUserPass(USER, PASSWORD);
- Get your Google Maps API key by following the instructions detailed in Google Maps Get Started.
Add the API key to your
AndroidManifest.xml
:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIza..." />
- If you are targeting Android Pie devices, add Apache Http Legacy to your
AndroidManifest.xml
:
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
-
By default, the wayfinding library will include a
ToolBar
with the situm search feature.- Tell your activity or app theme that you already use one by adding these lines to your styles.xml:
<item name="windowActionBar">false</item> <item name="windowNoTitle">true</item>
- Or remove the Situm search toolbar setting to
false
thesitum_has_search_view
property of yourSitumMapView
:
<es.situm.wayfinding.SitumMapView ... app:situm_has_search_view="false" />
-
Make sure to extend AppCompatActivity. If you chose not to use the
situm_search_view
feature you can just extend FragmentActivity. -
Right now, the
minSdkVersion
must be16
or greater.
We have created some samples that show different use cases of this module
The simplest way to use our module is by creating an empty activity and including SitumMapView
in the layout file.
For more information, please refer to ActivitySampleSimpleMap.java
.
If you want to get notified about what happens inside the module, your activity should implement the SitumMapView.OnMapReadyCallback
interface:
For more information, please refer to ActivitySampleLogEvents.java
Under some circumstances you may prefer to control the exact moment at which the underlying maps fragment is loaded. If that is your case, just use the SitumMapsLibrary
object as described in ActivitySampleUsingLibrary.java
.
The Situm Map implements some convenience actions for onBackPressed
Android events:
- When there is an active building selected: zoom out to see building markers again.
- When a POI is selected: deselects the current POI.
- When a route has been requested: cancels the current route.
- When an event is triggered: closes the event dialog.
If you want to keep this behaviour in your application, just delegate each onBackPressed
as described in ActivitySampleDelegateBackEvents.java
.
You can use your own logo and color scheme in the module.
- Define an organization theme in your Situm Dashboard.
- Tell the module to use the organization theme. For that, see
ActivitySampleDashboardTheme.java
.
If you want to remove the default situm_search_view
feature, please refer to ActivitySampleNoSearchView.java
.
The wayfinding module builds default location, navigation and directions requests. You may want to configure those requests before they are dispatched to the underlying SitumSDK.
If that is your case, please refer to ActivitySampleCustomizeRequests.java
.
More info is available at our Developers Page.
For any question or bug report, please send an email to [email protected]