Category: Intermediate

  • [TUT] Android Things – Writing a PIR Motion Sensor Driver

    This blog will show you how to write an Android Things driver for the HC-SR501 PIR Sensor Module. This module can detect movement and uses a GPIO pin on your Android Things board for communication. What are we going to do: – Understand how HC-SR501 PIR Sensor Module works – Write a MotionSensor interface for…

  • [TUT] Using Firebase with a Node JS Amazon Lambda

    This tutorial will show you how you can use Firebase in an Amazon lambda, two methods will be outlined used the Firebase javascript SDK and using the Firebase REST API. This post is going to cover the use of the realtime database. You might want to use the RTD in a lambda so that all…

  • [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…

  • Enchant your users, without boring them with repetition – Animations

    I hope you know the Android Design Principles, if not shh quick read them here. There is also a great talk on the principles from Google IO, so if you prefer video click this. Here I want to talk about animations in your application. Animations are great, they can create a delightful, enchanting experience. Animations…

  • [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] 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…

  • [TUT] DayDreams are as easy as counting sheep

    DayDreaming is simple, if you have written an application with an Activity i.e everybody! You should be able to implement a simple daydream with little extra effort. We are going to run through creating one and it will look something like this at the end: (much smoother on a device, this is a GIF representation)…

  • [TUT] Validate EditText User Input with Shake Feedback

    I was recently watching the Google App Clinic and noticed one of the apps Zoum Tasks had this really cool feature where when the user enters an email address into an EditText, if it was invalid then the EditText would shake! I thought this was really cool and wondered how it was implemented so I…

  • [TUT] Using the camera with a custom overlay

    This tutorial shows you how to use the devices camera inside your application. It also shows how you can have a custom UI for your camera and overlay images on top of the camera preview. I’ll apolgise now my graphics aren’t the best, but they convey the idea and concepts of what is possible. The…