Category: Tutorial

  • [TUT] Android Things – LEDs, GPIO on the Rainbow Hat

    This blog will show you how to use the LEDs of the Rainbow hat peripheral. In learning about how to make the LEDs blink, we will use the GPIO protocol which can come in handy for numerous other sensors and peripherals. Hardware Prerequisite: We have the Rainbow Hat connected to the top of our raspberry…

  • [TUT] Your First Android Things Application

    This blog is going to show you how to write your first Android Things application. We’ll discuss the hardware details you need to know to get started and then dive into the code of the android app. Prerequisite, I assume you have a Raspberry Pi (or other AndroidThings compatible board) and you have flashed it…

  • [TUT] Testing Android Things – Unit & Vendor tests

    This tutorial will show you how you can architect your Android Things applications to make testing much easier. This involves two types of testing: unit and vendor testing. Google has just announced the amazing Android Things. This gives the Internet of Things (IoT) a real jump start with the availability of the Android ecosystem and…

  • [TUT] Programmatically create a RippleDrawable of any color

    This tutorial is going to be quick and to the point. When you want to create a Button or other Android Widget you more than likely want a ripple effect when it is pressed. I’ll show you how to do this. What we’ll do: – Create a simple RippleDrawable – Ensure it reacts to touch…

  • [TUT] How to test time and control System.currentTimeMillis

    This post explains how to control time and specifically control System.currentTimeMillis. To make your code more flexible, maintainable and in the end testable! Showing an example application that uses time to define different behaviour for the app in the morning and in the evening. Going on to unit test this in a robust manner. What…

  • [TUT] Creating comments with timestamps like YouTube

    Creating comments with timestamps like YouTube (java.util.Date or JodaTime) This tutorial shows how you can create timestamped messages like the YouTube comments section. What this means is we will convert the timestamp (date) that each message has been saved at into a human readable and rounded format. For instance if today is 2016/02/14 17:00 and…

  • [TUT] Send app data to a web spreadsheet (Google Sheets)

    Have you ever had a spreadsheet and thought it’d be really good if I could get data into this from a mobile app. What a great idea, next comes the thought that this is actually much more effort than it seems. Well not any more, this tutorial explains how you can take input in an…

  • [TUT] Mocking shared preferences to test in isolation

    Below is an excerpt from my book “Learning Android Application Testing” that explains how you can write tests that interact with the Android system using files, databases or shared preferences without corrupting or being affected by the data that already exists. It’s post Christmas and there is a flurry of consumerism whilst the shops do…

  • [TUT] Front Camera Face Detection – with preview

    This is a continuation on my last face detection tutorial (here) that took you through the basics of retrieving the camera and giving user feedback when a face is detected. Including best practice when loading the camera, how to ensure you always release the camera when finished, get callbacks when faces are seen and when…

  • [TUT] Front Camera Face Detection – explained

    This tutorial explains everything needed to detect faces with the front facing camera on Android. It also wraps this all up into one class, so that you can do face detection in your activity with two lines of code. At first I had no intention of writing a tutorial as I thought face detection would…

  • [TUT] Locally release an Android Library for JCenter or Maven Central inclusion

    This post will put you on the right path to releasing and Android library to bintray ( JCenter ) or maven.org ( MavenCentral ). It will show you how you can create a maven compatible release of your Android library project. You can then use these files to release to whatever repository you want (in…

  • [TUT] How to run Robolectric JUnit tests in Android Studio

    After my blog post on describing an Android Gradle App with Robolectric JUnit tests. I follow up here with how to run these tests within your AndroidStudio. The outcome being faster feedback from your tests and great IDE integration. Ok here we’ll explain how to create a run configuration that will run all the tests…

  • [TUT] Migrating to AdMob in Google Play Services from AdMob SDK jar

    Google have announced AdMob will now be available from with the Google Play Services library. The issue being they are stopping delivering ads to the AdMob sdk jar from August 2014. I describe here some simple steps to help you migrate. This post assumes you originally were using AdMob sdk version 4 or lower. With…