1. Tutorials
  2. Android Things

Getting started with M2X and Android Things™

Setup M2X Android Client Library

To setup your project with the M2X Android client library following these steps:

  1. First, you'll need to add network permissions to your project's AndroidManifest.xml file:

    <uses-permission android:name="android.permission.INTERNET" />
  2. Next, setup your project to include the M2X Android client library using the Maven central repository following these steps:

    1. Add Maven Central Repository to your projects top level build.gradle :
      buildscript {
          repositories {
              mavenCentral()
          }
      }
    2. Add M2X Android Library as a dependency in /app/build.gradle, replacing "MAJOR.MINOR.PATCH" with the target version number for the M2X Android library, see full list of version releases here :
      dependencies {
          compile group: 'com.att.m2x', name: 'android', version: 'MAJOR.MINOR.PATCH'
      }

Configure Project for Android Things

Based on the Android Things project setup documentation, the following steps are required to setup your Android project so that it will run on Android Things:

  1. Update your SDK tools to version 24 or higher

  2. Update your SDK with Android 7.0 (API 24) or higher

  3. Create or update your app project with the following:

    • Add the dependency artifact to your app-level build.gradle file:
      dependencies {
          ...
          provided 'com.google.android.things:androidthings:0.1-devpreview'
      }
    • Add the things shared library entry to your app's manifest file:
      <application ...>
          <uses-library android:name="com.google.android.things"/>
          ...
      </application>
    • Declare a home activity as follows:
      <application
          android:label="@string/app_name">
          <uses-library android:name="com.google.android.things"/>
          <activity android:name=".HomeActivity">
              <!-- Launch activity as default from Android Studio -->
              <intent-filter>
                  <action android:name="android.intent.action.MAIN"/>
                  <category android:name="android.intent.category.LAUNCHER"/>
              </intent-filter>
      
              <!-- Launch activity automatically on boot -->
              <intent-filter>
                  <action android:name="android.intent.action.MAIN"/>
                  <category android:name="android.intent.category.IOT_LAUNCHER"/>
                  <category android:name="android.intent.category.DEFAULT"/>
              </intent-filter>
          </activity>
      </application>