Ireckon Development

Ireckon is an Android Wear watch app which provides users a fun “quiz on their wrist”. They are given a stream of questions and can then vote for their favourite answer by tapping on the watch screen. One example question would be: “Who your favourite Harry?” with the possible answers being Prince Harry, Harry Styles, Harry Potter, and Harry Houdini. The totals for the answers can be viewed on the companion website http://ireckon.fife-v.com

Ireckon on a watch

Ireckon on a watch

The goal was to write a dedicated watch application rather than a standard Android app which would then have Wear capabilities added later. Many Wear apps are actually Android phone apps with minimal Wear additions, mostly using the in-built notification system.

Ireckon was designed to have no companion app visible on the phone, although there does need to be a service app running on the phone for the watch to send messages to. This “hidden” app provides the server communications, sending data from the watch to the server and returning the server’s answers to the watch.

The core communications model is based around a question-answer pair. The watch app asks for a question which the phone requests from the server. The server sends over a JSON response which the phone passes back to the watch. The phone only runs the communications service for a second or two to send requests to the server and get the JSON response, minimising the battery drain on the phone.

Ireckon question

Ireckon question

Ireckon answer

Ireckon answer

A major hurdle with the Ireckon project was trying to get the four “answer” buttons to be the same size. This is because the button’s default action is to change size depending on the text, leading to buttons of varying sizes in relation to the number of characters in the answers. Just inserting the buttons into the GridLayout didn’t work. I would have expected that there would be an option for the GridLayout which would force all the cells to be the same size but the nature of the buttons meant that they tried to resize to the text. This meant that they would become very wide. One solution would be to insert newline characters to force buttons with long text labels to wrap but this meant that the server side would have to hold them too and we would have to figure them out at one end. The successful solution to this was to get the height and width of the GridLayout and divide it by the number of rows and columns respectively, using those values to set the buttons’ dimensions. The text would now be forced into the set size of box and wrapping would happen automatically.

Another challenge came when we decided to add more questions. Originally you would just come to the last page which would say “No more questions” but we wanted to be able to dynamically add extra questions. This meant that the Wear app would need some way of being notified that there were new questions available. We solved this by starting a polling service which asks the server every six hours how many new questions are available. The API call is set up so that if the watch asks for a new question it responds not only with the question but how many more new questions are now available.

We used the Alarm Manager to achieve this polling solution but we did first consider using the Google Cloud Messaging Service (GCM).  The GCM uses push notifications to send new information to users, but this proved to be too complex and excessive for this app. If updates needed to be urgently pushed out then the GCM would be the ideal solution. The remaining issue with relying on the Alarm Manager is that if the phone has no internet connection then it can’t poll. Also, if there’s no watch connected at the time then the notification can’t be delivered. So both of these conditions have to be met for the notification to be successfully sent.

 

Download the Wear app

View the current total percentages