Implementation
Once new project is created , in build.gradle file add dependencies for android things.
dependencies { … provided ‘com.google.android.things:androidthings:0.1-devpreview’ }
Also in application’s manifest file add:
<application …> <uses-library android:name=”com.google.android.things”/> … </application>
Android Things is streamlined for single application use. So define an intent filter with Category IOT_LAUNCHER, which will make that activity run on device boot. While development, define this same activity as LAUNCHER so that Android Studio can launch that when deployed.
<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>
And that’s it. Next you can connect some sensors, display to board, communicate between them using Android Things’ peripherals API.
Key points to remember while developing Android Things
- Android Things extends the core Android framework with additional APIs provided by the Things Support Library. It does not include standard suite of system apps and content providers.
- Avoid using common intents and content providers API like CalendarContract, ContactsContract, DocumentsContract, DownloadManager,MediaStore,Settings, Telephony, UserDictonary, VoiceMailContract.
- Android Things supports graphical user interfaces using the same UI toolkit available for traditional Android applications. In graphical mode, the application window occupies the full real estate of the display. Android Things does not include the system status bar or navigation buttons, giving applications full control over the visual user experience. However, Android Things does not require a display. On devices where a graphical display is not present, activities are still a primary component of Android Things app, this is because the framework delivers all input events to the foreground activity, which has focus.
- Unavailable APIs: AdMob, Android Pay, Firebase App Indexing, Firebase Authentication, Firebase Dynamic Links, Firebase Invites, Firebase Notifications, Maps, Play Games, Search, Sign-In.
- Supported APIs: Cast, Drive, Firebase Analytics, Firebase Cloud Messaging, Firebase Crash Reporting, Firebase Realtime Database, Firebase Remote Config, Firebase Storage, Fit, Instance ID, Location, Nearby, Places, Mobile Vision.