Damian Walker

Personal Web Pages

Android Development Diary

Android Development Blog

In May 2015, I started to learn how to develop for Android. My aim is to create board game apps for my phone and tablet. But I have to start with much simpler than that.

When I started, everything seemed so Byzantine. The developer tutorial at http://developer.android.com/ starts very well, but after the first lesson it suddenly starts to assume a level of knowledge and competency that the first lesson doesn't impart. So I've had to turn to other sources.

This blog is written as much for me as for anyone else. It's a record of the problems that I've encountered, particularly things that have held up my progress for a significant amount of time. Hopefully it will save me having to remember which of the many helpful sites gave the solution to each problem.

An Invisible ImageView Peculiarity

26 Jun: This morning I had a little bit of difficulty with a custom ImageView on a new project. The image wasn't being displayed at all. In fact, putting "Toast" messages in the onDraw method to inspect the running revealed that the onDraw method wasn't being called at all! The bitmap in this view isn't loaded from a png, but generated at runtime; it's a game board, and its content comes from a conceptual board object (currently empty, but at least ... (read more...)

Unrecognised Device in Linux

getting-devices-connected

20 Jun: I've been doing Android development almost exclusively on my laptop till now. That's because Android Studio on my desktop computer didn't recognise the Sony Xperia I'm using to test my app in development. When the laptop had the problem I updated Android Studio and that seemed to fix the problem. But an upgrade on the desktop didn't have the same result, so I had to dig further. Typically when building and running the app, the device list would pop ... (read more...)

Indentation in Android Studio

android-code-style-settings

18 Jun: Since I last blogged, I made a lot of progress with just about no real road blocks. I'm implementing an Android implementation of Steve Meyers' excellent BoxOff puzzle as my first project. One niggling thing has been annoying me as I code, though. I like my code indented by four spaces. I like short lines, so that if necessary I can print the code out on a printer or casually browse through it on an 80-column screen or terminal ... (read more...)

Untangling Java classes, or Not

30 May: Since I'm at the stage where I can start thinking about developing an actual game, I decided to tidy up my decade-old board game applet code for inclusion in an Android project. This code was my first major object-oriented project, and works quite well (or it did, till Oracle's security clampdown prevented most people from running it at all). Tidying it up involves a number of things. Some classes' names could have been better chosen, so those could be ... (read more...)

Scaling Part II: the Game Begins

the-beginnings-of-a-board-game-app

27 May: The next step of my development learning curve is to learn to manipulate images. In particular, I want to take a board graphic and put pieces on it. I'm making small steps at a time, so my first trick is to plonk a piece on a set position on the board. The most suitable way "perhaps for a chess game...or another slowly-animated application", the Android developer site tells me, is to draw straight onto a custom view. If one ... (read more...)

Scaling with Aspect Ratio

21 May: I was very pleased with having built my first functional app, which shows one image and allows the user to select a menu option to change it for another. But the simple layout I have adopted keeps the image small, and displays it in the top left corner of the screen. One of the things I'll want to do when writing a board game app is to scale the board to take up the available width of the screen, ... (read more...)

A Breakthrough!

20 May: As a first step towards writing a board game app, I wanted to display an empty game board on the screen. This can be done very easily in Android, without any Java. You just have to add an <ImageView> tag in the relevant layout XML file, and include the src attribute like you would in an HTML document. I did this at first and it worked well. But then I wanted more control over the image: on loading ... (read more...)