Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android Things Quick Start Guide

You're reading from   Android Things Quick Start Guide Build your own smart devices using the Android Things platform

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789341799
Length 192 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Raul Portales Raul Portales
Author Profile Icon Raul Portales
Raul Portales
Arrow right icon
View More author details
Toc

Design concepts behind Android Things

We have talked about the vision that drives Android Things. Let's now look at the design considerations as a platform that are reflected in how it works and the options it gives to us, namely being designed without the requirement to have a display, the meaning of Activity and Home, and a different way of working with permissions and notifications.

Displays are optional

The most significant characteristic of Android Things is that it has been designed to work without a graphical user interface. This is a very logical decision if you consider that most IoT devices do not have a screen. It is important because it dictates that all the APIs that have a strong requirement for a screen need to be redesigned or disabled/removed.

Quite often, this design decision is misunderstood as that Android Things does not support graphical user interfaces. That is not correct. You can use the same classes as you would do when building a UI on Android, the same way to create layouts and assign them to an activity. Those layouts will work fine and you can rely on them if you are building a device that has that sort of interface, but it is not a requirement for an Android Things project.

If you want to build a UI for Android Things, you can do it in the same way you would do it on Android.

One small difference is that Android Things does not have a status bar or navigation buttons and, therefore, the application window takes all the real state of the display. This also implies that there is no way of displaying notifications on Android Things, so the Notification API is not present

Although you cannot display notifications on Android Things, you can use Firebase Cloud Messaging to send messages to your app to trigger events.

Finally, even though you may not have a UI, the key component we will use to build our applications is the Activity, but, in many cases, it will not have a visual component.

Home activity support

Similar to Android home screen launchers, Android Things supports the concept of home, and it is defined the same way. This is the application that will run when the device boots. We will see how this is declared later in the chapter when we explore the default project of Android Things.

An IoT device will usually have a single purpose, in contrast with mobile phones that have multiple apps that can be launched. That single purpose is what the Home application does.

IoT devices usually have a single purpose. We use the Home application to define it.

While developing, you can launch apps in the same way you can on Android phones, also having them declared on the Manifest. This is useful for quickly testing some ideas, especially if you are just playing around with simple apps and do not want them to become the home app, but keep in mind that you won't have the ability to launch them in any other way.

Permissions

Granting permissions to apps is a good example of a feature that has been redesigned because having a display is not mandatory. In Android, permission requests are pop ups that ask the user. So how do we do this without a user interface?

Firstly, the permissions are declared in the same way as you would do for an Android app; you just add them to your Manifest.

Then, permissions are granted at install time, either with Android Studio when you are developing, or via the Android Things Console if you include the app for distribution.

You can also use adb to grant and revoke permissions

Android Things Console

Android Things provides a console that has a similar role to the Google Play Console for mobile apps, although its functionalities are quite different.

The key functionalities that the console provides to developers are:

  • Downloading and installing the latest Android Things system image
  • Building factory images that contain OEM applications along with the system image
  • Pushing over-the-air (OTA) updates
  • Managing OEM applications
  • Analytics

The Android Things Console will help us with distribution.

It is intended to be used when you move to mass production and you want to build the image to be flashed on your boards.

Given the nature of this book, the console is not something we will be exploring. We will just use it to download the script that flashes the default image on the developer kits.

Supported APIs

Android Things relies heavily on Android libraries to offer flexibility and functionality. Given that Android Things is optimized for embedded devices that may not contain the same feature set as an Android phone or tablet, not all the APIs are present. In most cases this is coming from the restriction of not requiring a UI. There is a reference list of system APIs and Google APIs that are supported and unsupported in the Appendix.

You can use hasSystemFeature() to determine whether a given device feature is supported at runtime.

As a rule of thumb, if it requires a system service -such as a calendar or telephone- or a strong UI component -such as AdMob or Sign-in- it is likely to not be supported, but the number of available services is remarkably large.

You have been reading a chapter from
Android Things Quick Start Guide
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789341799
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image