Getting Started

Fedor Puchkov edited this page Mar 7, 2018 · 12 revisions

To start using Navigation library in your project you should do the following steps.

The full NavigineDemo project (with sources) can be downloaded here.

Step 1

Register on, create a location and get your personal security key in the profile (it has the form 16 hexadecimal digits: XXXX-XXXX-XXXX-XXXX).

Step 2

Download "NavigineSDK.jar" and add it to the Android project. For Android Studio users this page may be useful: Android Studio Integration.

Step 3

Initialize Navigation library in your code before any other library functions are called. Don't forget to check the return code of the function:

// Initializing Navigation library (USER_HASH is your personal security key)
if (!NavigineSDK.initialize(getApplicationContext(), USER_HASH, null))
   Toast.makeText(this, "Unable to initialize Navigation library!",

If function returns false Navigation library is not initialized and cannot be used. This generally happens in one of the following cases:

  • Android SDK version is less than 18;
  • Android device doesn't support Bluetooth 4.0;
  • CPU architecture is not supported yet.
Step 4

Download a location archive from the server using the following (or similar) code:

class LoadTask extends AsyncTask<Void, Void, Boolean>
  @Override protected Boolean doInBackground(Void... params)
    return NavigineSDK.loadLocation(LOCATION_ID, 30) ?
           Boolean.TRUE : Boolean.FALSE;
  @Override protected void onPostExecute(Boolean result)
    if (result.booleanValue())
      // Location is successully loaded
      // Do whatever you want here, e.g. you can start navigation
      NavigationThread navigation = NavigineSDK.getNavigation();
      if (navigation != null)
      // Error downloading location
      // Try again later or contact technical support
      Log.d(TAG, "Error downloading location!");
(new LoadTask()).execute();
Step 5

If location archive was successfully loaded you can start navigation (see NavigationThread for details). Periodically (1-5 times/sec) you should update the navigation results and display them to the user. Here is the example code:

void updateNavigationResults()
  NavigationThread navigation = NavigineSDK.getNavigation();
  if (navigation == null)  // Check if navigation is available

  DeviceInfo info = navigation.getDeviceInfo();  // Get device position
  if (!info.isValid())
    // Navigation results are not available
    // Try to find out the problem using navigation error code
    switch (info.errorCode)
      case 4:
        Log.d(TAG, "You are out of navigation zone! " +
                   "Check that your bluetooth is enabled!");

      case 7:
         Log.d(TAG, "Not enough reference points on the location!");

      case 8:
      case 30:
        Log.d(TAG, "Not enough beacons on the location!");

        Log.d(TAG, "Something is wrong with the location! " +
                   "Error code " + errorCode);
    Log.d(TAG, String.format(Locale.ENGLISH, "Device %s: [%d/%d, %.2f, %.2f]",
, info.location, info.subLocation, info.x, info.y));
Step 6

When application finishes using Navigation library, don't forget to finalize it:

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.