01 – Android quickstart guide

In this tutorial, we will guide you step by step to set up your first application using Situm Wayfinding Module. We have also prepared a sample app that shows how to use the Situm Wayfinding Module in different situations.

Configure the WYF module in your Android project #

First of all, you must include the Wayfinding Module in your Android project. To do this, first of all you should add the maven repository either to your project’s “build.gradle” file (for Gradle versions <=6) or to your “settings.gradle” file (for Gradle versions >7).

//Add this to your Project's "build.gradle" file

allprojects {
    repositories {
        maven { url "https://repo.situm.es/artifactory/libs-release-local" }
    }
}
//Add this to your Project's "settings.gradle" file

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url = "https://repo.situm.com/artifactory/libs-release-local"
        }
    }
}

Then add the Situm WYF library dependency to the “build.gradle” file (to the individual module file, not to the project’s “build.gradle” file). You must specify your desired SDK version (see Changelog for details) and add the transitive = true property to download the Situm SDK dependencies.

//Add this to your module's "build.gradle" file

dependencies {
 
    ...
    implementation ('es.situm:situm-wayfinding:X.Y.Z-alpha@aar') {
        transitive = true
    }
}

Set your Situm credentials #

There are two ways to set the Situm credentials, in the AndroidManifest.xml file or programmatically.

Option 1: AndroidManifest.xml #

You can set the credentials (user and API key) in the AndroidManifest.xml file adding the next meta-data fields:

<?xml ...>
<manifest ...>
    <application
    ...>

        <meta-data
            android:name="es.situm.maps.API_USER"
            android:value="SITUM_USER_EMAIL" />
        <meta-data
            android:name="es.situm.maps.API_KEY"
            android:value="SITUM_API_KEY" />

        ...
        <activity ...></activity>
    </application>
</manifest>

Option 2: Programmatically #

In the code, you can set the the user and API key with:

librarySettings.setApiKey("SITUM_USER_EMAIL", "SITUM_API_KEY");

or you can set the user and password with:

librarySettings.setUserPass("SITUM_USER_EMAIL", "SITUM_PASSWORD");

Configure Google Maps #

Situm WYF uses Google Maps as a base layer, on top of which everything else is drawn: floorplans, routes, user’s location… More concretely, it uses the Dynamic Maps service, which has a generous free tier.

First, you should create an API Key for your project. Then, add the API Key to your “AndroidManifest.xml” file:

<?xml ...>
<manifest ...>
    <application
        ...>

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="GOOGLE_MAPS_APIKEY" />
   
        ...
        <activity ...></activity>
    </application>
</manifest>

Other configurations #

Android Pie Devices #

If you are targeting Android Pie devices, add Apache Http Legacy to your “AndroidManifest.xml”:

...
   <application ...>

      <uses-library
        android:name="org.apache.http.legacy"
        android:required="false"/>

   <application/>
...

Toolbar #

By default, the wayfinding library will include a “ToolBar” that implements a POI search feature. In order to work, you should either tell your activity or app theme that you already have a Toolbar by adding these lines to your “themes.xml”

<resources ...>
    <style ...>

        ...
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>

    ...        
    </style>
</resources>

or remove the Situm search Toolbar by setting to “false” the “situm_has_search_view” property of your “SitumMapView” (see next Section to know what the SitumMapView is):

<es.situm.wayfinding.SitumMapView
    ...
    app:situm_has_search_view="false" />

Add SitumMapView #

Option 1: Programmatically #

Adding the view in the xml it’s easier and faster but it doesn’t allow you to interact much with the module. This is solved by adding the view programmatically. To do this follow the steps:

First, inside of your layout you need to add a view where the map is going to be:

<FrameLayout
        android:id="@+id/maps_library_target"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

After that in the onCreate method of your activity you need to initialize the module:

@Override
protected void onCreate(Bundle savedInstanceState) {
        LibrarySettings librarySettings = new LibrarySettings();
        librarySettings.setApiKey("user", "apiKey");
        SitumMapsLibrary mapsLibrary = new SitumMapsLibrary(R.id.maps_library_target, this, librarySettings);
        // This method is the one that loads and start showing the module
        mapsLibrary.load();

Option 2: From XML #

In your layouts/activity_main.xml file declare the SitumMapView:

...
<es.situm.wayfinding.SitumMapView
    android:id="@+id/map_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
...

Enjoy your new app! #

After doing this the module will be shown and it can be used. If you want to interact more with it you can use the classes “LibrarySettings” and “SitumMapsLibrary” to do it.

That’s it! You will be able to build and run this app. Try it out and for more advanced uses, go to our sample app in Github.

Subscribe to our newsletter

BASIC INFORMATION ON DATA PROTECTION

Data controller: SITUM TECHNOLOGIES, S.L.
Contact: Data controller: situm@situm.es
Responsible for protection: dpo@situm.es
Purpose and legal basis: To manage the sending of SITUM newsletters only with consent.
Legitimation: Express consent of the interested party.
Recipients: The data will not be passed on to third parties with the exception of legal obligations.
Retention period: As long as the interested party remains subscribed to the newsletter (a link to unsubscribe will be available in each newsletter sent by Situm).
Rights: The interested party may at any time revoke their consent, as well as exercise their rights of opposition, access, conservation, rectification, limitation, deletion of data and not be subject to a decision based only on automated data processing, by writing to SITUM at the addresses indicated.
Additional Information: You can consult additional and detailed information on Data Protection in our privacy policy.

Please, download your copy here

Thank you for downloading our whitepaper. Please do not hesitate to contact us if you would like to know more about how our solutions can help your business. Download whitepaper


Close window