Wednesday, 20 July 2011

Getting started

I've started to use Android more and more. Building my own app seemed like the next step, so I've had a go. I have decided to write a blog, partly as a record of progress, partly as a way to write down useful stuff and partly to help clear my thinking.

Developing in isolation can be hard work, especially learning a new language or a new API. The Android environment is substantial and there's plenty to learn. I've read a few books - the best of which is the Professional Android 2 Application Development by Reto Meier. The books got me started and gave me enough information to start to write stuff for myself - which is where the real learning begins.

Android development is usually done with Java; actually a Java-like implementation known as Dalvik, but very much like Java.  I followed the recommendations of more than one place and installed Eclipse (on Ubuntu). It works well enough and I am getting used to it. I have written stuff in Java before, but not extensively. It is quite funny when the advice tells me to be very careful about memory use, the first home computer I had only had 4k of memory so an Android phone is huge by comparison. The first mainframe I wrote programs for had little more memory than that and almost no available disk space, all big files were on tape. I have long grumbled about the wasteful way programs are written, so I should be at home here.

The terms and names are quite different from other environments, but that is normal. The place information is displayed or edited is an activity. This might be a form, screen, window, frame or page elsewhere. The means of communicating between activities, and more widely uses an intent. This could be a message elsewhere. Intents are flexible, with an open-ended way of attaching data to the intent. My biggest niggle with them so far is that it is not easy to pass an object with an intent.

The recommended way of creating an activity layout is to specify an XML file that defines the layout. In fact the recommended way of specifying everything is in an XML file, so text in messages and the titles of fields should be all specified in an XML file. Part of the reason for this is that there can be multiple versions of these XML files for different device sizes and different locales and languages. This seems like a great idea, but I know that translating something is not as simple as substituting translated words. Maybe it will work well.

So far the simple stuff I've written I've stored locally and backed up to a USB disk. I think I may look into using github from Eclipse. That would provide a way to share anything that is useful and provide another copy off-site.

My next task is to understand the activity life cycle a bit better. It is vital to know what happens and when because the life cycle is not in the hands of the programmer, which feels a bit odd. I also want to understand the best way to store data being used by an activity; is that an object created for the purpose, or fields of the activity, or data attached to an intent or something I haven't seen yet. In such a heavily object-biased language as Java, I'll start there.

No comments:

Post a Comment

Thank you for taking the time to add a comment.

I have decided, regrettably, to review comments before they are published to ensure that offensive or inappropriate comments do not get shown.

Genuine comments are always welcome and will be published as quickly as possible.