So upfront I will admit that I am not one of life’s readers-of-instructions. I tend to skim through manuals and instructional pages and just get a sense of what I need to know then dive in and start pressing buttons.
So when I’m learning a new development language or library, I mostly look for an example I can pull apart and restructure to suit what I’m after. In that regard the Android development instructions available are really very good, and I enjoy the style. Mostly there are pages that give a fairly high level idea of the kinds of objects and usage patterns you need to use for various things, then link to examples that show them being used.
In my case I’m picking through the LunarLander example to get an idea of how to work with SurfaceViews and do some custom rendering.
As helpful as that has been, I have found myself getting very familiar with one dialog pop-up in particular.
Unfortunately has stopped : OK
As a user I guess this is about as much as you are interested in knowing. As a developer I kind of wish there was a button that would take me of the stack trace of what went wrong. So far I have not investigated the ‘right’ way to debug such errors. However I do have a way.
The first thing I tried when looking at android development was the rather awesome AIDE, a whole android development environment that runs on an android device! I loved that I could create a sample app, start hacking it around, hit ‘run’ and be running the new app in a few seconds right there. In someways it was AIDE that rekindled my interest in developing for mobile by reminding me that it really could be quite easy to get going. The fact that I wound up being drawn into a much more ‘serious’ development environment of eclipse/git/jenkins was mostly because AIDE gave me a chance to think about some ideas and decide I had one I really wanted to work on.
In my playing with AIDE I found it had an option to ‘view LogCat’ which basically shows a tail of the system log. The first thing I noticed in this was that there are errors happening in software under the hood all the time. The second was that I could see the errors of my own app.
So now, I know I can trigger an error in my app, switch to AIDE and normally catch the error in the log. There is an issue that if you’re not fast then the error disappears as the log buffer isn’t that long. However, so far it’s been all I need to get a glimpse of the underlying exception that has lead to my downfall.
So far all my issues amount to figuring out the life-cycle of an android app and the state transitions I’m responsible for handling. Learning the right ways to ensure that state is persisted and restored at all the right points, hopefully without massively repeatedly doing calculations when they are not required.
As I write this my problem appears to be when flipping back to my running app after switching away. The calls to thread.start occurring again against an already running thread. At this point I wonder if I should have actually compiled up and installed the lunar lander example to check that it doesn’t not suffer the same failings, since I’m increasingly unable to figure out what my app is doing differently in this regard and getting into new code to guard the appropriate conditions.
Despite this on going issue with handling the application life cycle, I have thus far been very happy with my rate of progress. I had some fun rendering a QRCode from a bitmatrix. After briefly wondering if an existing library existed to perform the rendering, I realised that with the hard part done, eg some data encoded into a bitmatrix, rendering it out was actually trivial (as attested by the fact that my code to do so work first time). Now I’m playing with how transparent I can make them whilst still scanning reliably, and I may play with whether colour has any effect.
For the moment I’m happy to use a standard qr code reader to test with, but I think I will also play with integrating one myself, since I think it will be good experience.
My biggest problem with developing an android app turns out not to be the environment or the instructions, it is that the UK is experiencing something of a mini early summer. The weather has been so nice that between work and wanting to make the most of sunny weekends, I really don’t feel I should be spending time indoors at the computer more than I already do.
UPDATE: I did some searching and found others had the same problem using the LunarLander example, it has a bug in that it is not valid to call start on the thread again after the first time. the solution is to ensure the app exits on stop and therefore cleanly restarts when you switch back to it.