How to integrate vanillaNAV SDK in native Android apps


Purpose

This FAQ is meant to serve as a guideline for using the vanillaNAV library in a third party native Android application.

 

Library distribution

 

The vanillaNAV library is distributed as an Android library file in the AAR format.

The contents of this AAR file are:

  • Navigation Activity - which is used for the navigation functionality 

  • Favorite Location Save Activity -  used for saving a location (a POI or a navigation marker) and beeing able to navigate to it afterwards

  • C++ code for marker detection

  • Utility classes for the navigation functionality that enable the necessary computations  and data acquisition (like downloading the venue data)

 

Importing the Library

 

The AAR file has to be imported via a gradle script. See reference of this here.

To use your Android library's code in another app module, proceed as follows:

  1. Add the compiled AAR file:

    1. Click File > New Module

    2. Click Import .AAR Package then click Next

    3. Enter the location of the AAR file then click Finish

  2. Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "vanillanav-lib":

include ':app', ':vanillanav-lib'
  1. Open the app module's build.gradle file and add a new line to the dependencies block as shown in the following snippet:

dependencies {   compile project(":vanillanav-lib")}
  1. Click Sync Project with Gradle Files

 

Calling vanillaNAV Navigation

 

In an activity of your choice, import the following items:

import net.rosoftlab.vnlib.ui.navigation.NavigationActivity;

import static net.rosoftlab.vnlib.Constants.DESTINATION_ID;import static net.rosoftlab.vnlib.Constants.VENUE_ID;

 

Create an intent using your activity as the context and selecting the NavigationActivity as the target:

Intent intent = new Intent(this, NavigationActivity.class);

 

Add extra information to identify your venue and destination:

intent.putExtra(VENUE_ID, 12345);intent.putExtra(DESTINATION_ID, 67890);

 

The VENUE_ID is an unique identifier of the venue for which navigation shall be used, as configured in the vanillaNAV Manager web application

The DESTINATION_ID is an unique identifier of a destination (point of interest) inside the venue,  as configured in the vanillaNAV Manager web application

Please contact us directly to obtain information on how to get these IDs. 

 

Start the activity:

startActivity(intent);

 

Adding the Navigation Activity to the manifest.xml

 

The following line needs to be declared in your manifest to ensure the activity can be launched:

 

<activityandroid:name="net.rosoftlab.vnlib.ui.navigation.NavigationActivity"     android:launchMode="singleTask" />

 

The vanillaNAV library needs permission to access the camera and the internet. These permisions are declared within the library’s manifest.

 

Retrieving the List of Destinations

 

In order to access information about destinations or other data vanillaNAV uses to provide its services, access to the venue object is required.

A venue is the top level object that holds all the data regarding one location. All venues are stored online and they can be downloaded using the vanillaNAV public web API. This can be done by using the the API provided with the library.

This method uses the smartphone’s local memory to cache the venue and provide version control of the cache.

 

PublicApi api = Lib.getInstance(context).getPublicApi();

Observable<Venue> venueObservable = api.getVenue(12345);

venueObservable.subscribe(new Action1<Venue>() {

[email protected]

           public void call(Venue venue) {

               List<Destination> destinations =   venue.getDestinations();

           }

       });

 

Note that the library provides Observables of the data, using the RxJava library.

 

 

Last update:
2017-04-25 13:58
Author:
Marlene Lange
Revision:
1.6
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.