Tutorials Legacy ▶ Hands On

120x120-fingerprintAndroid users are a proud bunch.

So if someone smudges the screen of their pride and joy there will be hell to pay. Here's a fun application which does just that, and hopefully demonstrates some basic image handling tricks along the way. What we will build is an application to show a full screen image, actually some pretty flowers, whilst waiting for your victim to touch them. When they do - uh-ho, it looks like they've left a dirty great finger print there! 

Tutorial: WashYourHands! Skill: Beginner 71x16-rating2   24x24-play App   24x24-source Source

To get started we need to think about how the images are going to be managed. Android can display pretty much any type, so a good choice for the background would be a jpg, since it's smaller and retains great colour depth whilst not needing transparency, and a png for the fingerprint as we'll use the transparency to give some semblance of credibility to the effect.



We'll be using Eclipse and the Android plugin for this project, so please make sure you have the same setup as described in the Debugging with Eclipse tutorial. Start a new Android project and call it "Wash Your Hands". The images are placed in the /res/drawable-mdpi folder. We'll be using a custom View, which is just a regular one with a background image which we draw ourself, called FingerPrintsView. In other words, this shows a way to write Android apps which don't refer to any XML layouts at all - it doesn't matter what we put in main.xml as it isn't used.

We want our application to be interactive, so we need to add handlers. This is the term given to a hook in your code which will listen for certain events to occur, in our case a touch on the main screen.

Heres how it looks when running: