How to update your Android Things device using Barracks – Part 1

Android is a wonderful platform for making advanced devices: smartphones, tablets, set-top-boxes, smartwatches, TVs, etc. Recently, Google released the Developper Preview of Android Things, a custom version meant to be deployed on IoT Devices. However when it comes to creating your own ROM or Android distribution, you get the full measure of the challenges you are facing. We know that keeping your device up to date – for security reasons, major OS updates or new features delivery – is one of these challenges. Lucky you, Barracks can do this!

Here is how you can do this:

Update checks in background

First thing first: you need to be able to check for updates in the background.

Use Barracks to check for updates

Once you registered on Barracks and have located your API key, you will be able to use our Android Client library.

Clone the library as a subproject (we are working on publishing it on a maven repo to facilitate the access):

Add it to your project’s settings.gradle:

Then add the dependency to your application:

You are now ready to use our SDK in one of your activities or service.

Wake-up your app on boot

Your device’s update process should take place in the background. In order to do so, you’ll have to wake up your application when the device boots.

The easiest way is to register an intent receiver for the corresponding intent:

Check for updates on a regular basis

The previous example has a drawback: you will only check for updates when the device boots. Not a great solution, right ? Well, we’ll use the AlarmManager in order to make this operation on a regular basis (let’s say every hour, for the sake of this example).


In this post you’ve seen how to handle the “invisible” part of the update process, which consists in checking for available updates in the background, and downloading these updates. You also became familiar with the Barracks SDK for Android, which will handle all the basic operations and provide you with feedback.

The next blog post of this series will give you details on the visible part of the process : providing feedback in a nice UI, and respond to Android’s hidden requests!