Standalone integration for Sygic2D

Introduction

NOTE: We strongly recommend chosing integration with a lastest 3D version of Sygic Professional Navigation.

In the following we will guide you through creating a simple Android application integrating Sygic navigation engine with a standalone integration (Sygic runs on a separate screen in the fullscreen mode).
In this example we will develop a simple application, where you can type in an address string and through a custom button you can start navigation to that address.

Prepare your working environment

For being able to compile your application you need to have Eclipse ADT on your computer. If you don't have it please follow Download Eclipse ADT.
As the key point you need to Download and Install SDK library on your computer.
You may want to install the Sygic navigation on your device in advance. Check Installation of navigation. You will definitely need it at later stages when you want to test your application on device.
Not necessarily but we recommend first to test the compilation flow using the IpcDemo2D project within the Sygic SDK package. Check Run Demo Example.

Create new project

Let's start Eclipse and create the new project through File -> New -> Android Application Project.
The project is automatically populated with several files, while these are relevant.

MainActivity.java, which is the placeholder for application coding (java code)

activity_main.xml, which will define graphical look of application (layout form)

Note that all Sygic classes and functions are located in the package com.sygic.sdk.remoteapi.

Define graphical look

As envisioned we add two graphical elements into application, which is the EditText for inputting address and Button for triggering navigation functions.
Thus we need to modify the default generated layout to the following form.

The activity class needs to contain the instance of Sygic Api (mApi) and the instance of ApiCallback (mApiCallback).
The ApiCallback as the interface defines 3 functions mandatory to fill (onServiceConnected, onServiceDisconnected, onEvent).
In this example we will only use onServiceConnected. The other two functions we can leave empty in this example.
With the applicaton start (the application basically starts at OnCreate) we need to call the mApi.init function, which binds API with the defined callback and with Sygic navigation.

Bind API to Sygic Navigation engine

The binding means filling the appropriate application and service identificators into mApi.init function. in this example we use com.sygic.drive, which corresponds to Sygic 2D Fleet Navigation.

Invoke navigation function

We will call the navigation function from the button click on our designed button by filling its event function OnClick.
Inside OnClick we will read the user typed address and use it in the API function call NavigateToAddress.
Thus the whole function can be defined within default activity OnCreate function as follows:

Build and deploy application

Building the application is simple as clicking on Run button in Eclipse.
The result of the build process is generation of MyApp.apk, which just needs to be copied to your Android device.
You also need to copy and install Sygic Navigation to device. Please note in this example it should be Sygic 2D Navigation.
For binding to other versions of navigation please change the application identificator inside the Api.init function.
If you have not done that yet please follow Installation of navigation.