Hangman Android application

illustrations illustrations illustrations illustrations

Published on 25th March 2021 by Madeleine Smith

I built this Hangman game for the Android operating system when I was working in a project team as a full stack developer. As part of my job, I was building and maintaining both an Android and iOS app. I wanted to have a better understanding of how to build an Android app so decided to undertake one myself, from scratch.

To add a bit of context, my app enables a user to guess the letters of a pre-selected word. Any correct letter guesses are added to the word and incorrect guesses cause more lines to be added to the hanging man drawing. If the user is unable to guess the word within a certain number of guesses (in this case, 13), the man is hanged and the player has lost the game. Once a game is completed the user can choose to see the definition of the word or begin a new game.

portfolio-image
Here is my MVP - as you can see, design wasn't a priority at this stage 😜
Here is the finished app which is available on the Play Store

I built the app in Java and once I had programmed the basic MVP I decided to implement two external APIs within the game. Instead of having the user guess a word from a hard-coded array of words, I implemented the Wordnik API to retrieve a list of random words. I also used the Oxford Dictionaries API to retrieve the definition of the word being guessed.

After initially implementing the Wordnik API, I find playing the app with colleagues a rather amusing experience. I used their /randomWords endpoint which allows you to specify multiple parameters (such a number of words and max/ min number of characters) and you are returned a list of x random words.

Wordnik uses a parameter called corpus count to essentially define how commonly occurring you wish the words returned to be. The higher the corpus count, the more frequent the word in the English language. However, if you don’t set this parameter, words of any frequency are returned. So you can imagine our amusement/bemusement when trying to guess words we’d never heard of such as formins, stander or folio.

I’d love to say it was easy to get a list of fairly common nouns (I was thinking words such as house, umbrella, calendar etc…) from the Wordnik API but instead I found the experience rather frustrating. The endpoint allows you to specify which parts of speech you want to include/exclude by passing along a comma separated list. I wanted to include the noun part of speech and excluded basically everything else, especially the proper-noun and abbreviation part of speech. Though this doesn’t seem to work in practice, or at least that was my experience.

Even though I would specify to include the noun part of speech and exclude proper-noun I repeatedly received proper nouns from the endpoint. For example Turkey, Nicolas, Glastonbury, Kerri and Yahoo!. But if you hit the Wordnik /{word}/definitions endpoint individually with these words they are categorised as proper nouns (hence my confusion).

Tinder has nothing on me 😉

As I said, it was a bit of a frustrating experience and I think if I were to continue developing the app I’d hunt around for a better API (Words API looks fairly promising for my needs).

Moving on, after managing to figure out how to sign the app, I was able to publish it to Google’s Play Store (listing). This felt really satisfying to be able to see my work online and allow friends and colleagues to directly download the app. The app currently has a very impressive 5 star rating (though only because two friends added their reviews 😂).

A fun feature that I implemented was displaying word definitions on swipeable cards - similar to how Tinder displays their user profiles. This was actually remarkably simple to do and I used a library called Swipe To Dismiss Dialog. It was as simple as creating a layout file for the dialog and then specifying this file when chaining some of the library methods together. I think this feature looks pretty snazzy and it’s fun to have a play around with too.

Overall, this was a really fun project to build and having it as an Android app instead of a CLI (as I did with my bowling application) made it very easy to start playing with colleagues or friends. Seeing something that I had built on the Google Play Store is a very satisfying feeling and made all the frustrations that I had in building this worthwhile.


In need of a back-end engineer for your project? Get in touch to hire me for contract work 💯