What you will learn

You will learn:

  • to configure your gradle with our nexus server and our SDK
  • to configure the SDK in your application

Prerequisites - What you need to get started

  • A Nexus Account: The SDK is available through a private Nexus. You must have received an email inviting you to create your account on our Gitlab server
  • Your SDK user information: To initialize the SDK, your should have received a User, a Password and a Company name.
  • A BLE beacon: A configured beacon on your account is mandatory to test the application
  • An Android Device: You need a compatible Bluetooth Low Energy Android device that is able to detect beacons
  • The Android Studio application: Android Studio must be downloaded from the Android Developpers’ website

Step 1: Configure your access to our Nexus from Gradle

  • Create a .gradle folder at the root of your home directory (if one does not exist already)

    • be careful to NOT create it at the root of the project directory
  • Create a gradle.properties file inside the .gradle folder

  • Add the following parameters to the gradle.properties:

    • forgeMavenUser=The email associated to your Connecthings Gitlab account
    • forgeMavenPassword=The password associated to your Connecthings Gitlab account
  • If you don't remember your password, you can reset it here.

  • You can change the name of the parameters, but be sure to update them as well inside cBeacon’s build.grade file.

Step 2: Clone the sdk-tutorial repository

  • Clone the sdk-tutorial repository
git clone https://github.com/Connecthings/sdk-tutorial.git
  • Open the android>beacon>1-QuickStart>QuickStart-starter folder from the cloned sdk-tutorial folder

Step 3: Launch QuickStart in Android Studio

  • Launch Android Studio

  • Check that your Android SDK is up-to-date.

  • Click on "Tools > Android > SDK Manager”

    • Inside the SDK Platform tab, check that Android 6 has been correctly installed
    • Inside the SDK Tools tab, check that the Android Tools, the Android Support Library, and the various Google Services have all been correctly installed
  • In the Android Studio Wizzard, click on import project.

  • Or, if you already are inside an Android Studio project, go to "File > Open"

  • Select the android>beacon>1-QuickStart>Starter folder from the cloned sdk-tutorial folder

Step 4: Configure the project from Gradle with our nexus

  • Inside the Gradle section, open the project build.gradle file (the one named build.gradle(Project: Starter))
  • Add to to the section allprojects > repositories

    maven {
         credentials {
             username = forgeMavenUser
             password = forgeMavenPassword
         }
         url "https://forge.adtag.eu/nexus/content/groups/public"
     }
     maven {
         credentials {
             username = forgeMavenUser
             password = forgeMavenPassword
         }
         url "https://forge.adtag.eu/nexus/content/repositories/releases"
     }
     maven {
         credentials {
             username = forgeMavenUser
             password = forgeMavenPassword
         }
         url "https://forge.adtag.eu/nexus/content/repositories/snapshots"
     }

Note:

if you have named differently forgeMavenUser and forgeMavenPassword in your ~/.gradle/gradle.properties file, set the value accordingly in the gradle.properties of the project

Step 5: Configure the project from Gradle with our SDK

  • Inside the Gradle section, open the app build.gradle file (the one named build.gradle(Module: app))
  • Add the SDK with the appropriate version to the dependencies section:
  compile "android.connecthings.adtag:android-adtag-beacon:2.4.3"

Step 6: Configure the SDK inside the ApplicationQuickStart class

The AdtagInitializer

  • Open the ApplicationQuickStart class
  • Configure AdtagInitializer with the information your received from Connecthings inside the onCreate method.
      AdtagInitializer.initInstance(this)
                      .initUrlType(UrlType.DEMO / UrlType.PRE_PROD / UrlType.PROD)
                      .initUser("YOUR_USER",  "YOUR_PWD")
                      .initCompany("YOUR_COMPANY_KEY");

Note: The AdtagInitializer permits to configure the access to the various Adtag platform. Connecthings gives you access to three platforms :

  • The Demo platform is ideal for the technical Proof of Concept (POC) phase
  • The Pre-production platform is ideal for the beta versions
  • The Production platform is used when you're ready to publish your application

Warning 1:

Be sure to use the good access key login / password with the appropriate platform - for each platform (Demo/Pre-production/Production) you have received a specific access key.

Warning 2:

Connecthings send you a user to connect to the Adtag Platform and a user with an API KEY to be use with the SDK. Be sure to use the user with the API KEY to connect the SDK to the Adtag Platform, otherwise the application won't detect the beacons.

Warning 3: Connecthings send you two different access keys for each platform: - An access key to sign in the Adtag Platfrom - An access key to use with the SDK mobile, called API_KEY. Be sure to use the correct API KEY (login, password, and platform) to connect the SDK to the Adtag Platform, otherwise the application won't detect the beacons.

The AdtagLogManager

  • In the same method, after AdtagInitializer statement, initiate the AdtagLogManager
AdtagLogsManager.initInstance(this, Network.ALL, 200, 1000 * 60 * 2);

Note:

The AdtagLogManager permits to send the logs generate from the SDK to the Adtag Platform. Logs could be sent :

  • over all kind of network or only when the device is connected in WIFI
  • in batch of various size
  • every xx milliseconds

Step 7: Configure the manifest

  • Open the AndroidManifest.xml file inside the manifests folder
  • Add to the application tag, the name of the customized application class

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name=".ApplicationQuickStart" >
    </application>

Step 8 : test on your device

  • Check that your Android Device is in Developer Mode
  • Connect your Android Device to your computer
  • Activate your beacon
  • In Android Studio, click on "Play" to launch the installation process on your phone.