Learning the structure of an Android app is overwhelming at first, but it’s not too difficult after some familiarization. I recommend using Lars Vogel’s excellent Android tutorials here. They are among the best tutorials I have found, and I am sure I will keep using them as a reference as this project continues.
An Android app is made up of two parts: the front end and the back end. The front end is the visual part of the app that the user interacts with, and the back end, which contains all the code that drives the app.
The front end is written using XML. I have never used XML before, but it is very similar to HTML in that it is a markup language that uses nested tags as its programming structure. Android uses several XML files to create the app’s front end. There is at least one XML layout file for each activity (or several if you are supporting multiple device sizes), as well as layout files for custom views. XML is also used to define constant strings that will be placed in the layouts, such as the text on a button.
The back end is written in Java, which is great because it is a language that I am very familiar with. You can use the Java standard library in addition to the Android library when coding your app. This gives you access to a ton of pre-made objects, and the APIs are thoroughly documented online by Oracle and Google.
Each screen in an app is known as an activity. Activities are classes that you extend from a base activity class. Each activity is tied to an XML layout file which provides the front end visuals. Activities are created, resumed, and closed by the Android OS through a series of callback methods, which are called automatically by the OS at the appropriate times. Some examples of callback methods: onCreate, onPause, onResume, onStop. These methods have to be overwritten for your activity to work correctly.
Information sent between activities is called an intent. Intents carry standard data like strings or can be modified to carry custom extra data. For example, our AddTaskActivity creates a new Task object, adds it to an intent, and sends it back to the MainActivity where it will be displayed for the user.
There are other basics, such as fragments, services, and notifications, but I don’t know enough about them yet. I’ll comment on those after I’ve learned them!
From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.