Android 101: The Basics
Right now in the world of software development, writing mobile apps has become very popular. There's never been more choice in frameworks and the amount of smartphones available. While writing for iOS has been popular, it's Android that has caught the attention of Java developers. Over the next few articles, I'll be taking you through some steps to get started with Android. But before we get coding, let's take a look at some of the core principles of Android development.
What Is Android?
The following diagram, taken from the online developer guide, shows the architecture of the Android operating system:
The Android is built on top of a Linux kernel, for managing the typical operating system services. The Android runtime is based on the Dalvik Virtual Machine (subject of a lot of attention from Oracle these days). Dalvik is a slimmed down variation of the Java Virtual Machine, which builds on the Apache Harmony Java implementation. No JavaME, Swing or AWT components are provided; instead Android provides it's own library of components.
There are a number of native libraries available, all written in C/C++. Surface Manager deals with access to the display subsystem, while the Media Libraries provide playback for most popular audio and video formats.
It's the Application Framework that will interest most developers as this provides the API and services that you need to create quality mobile applications for Android.
The Core Android Concepts
As mentioned above, the Application Framework has everything that a developer needs for creating apps. Here's a rundown on the main concepts:
A activity is a user interface screen. One application can have one or more activities across the application's execution. Each activity that you create will be given it's own window to draw in. Each screen that you create will be a subclass of Activity.
A service runs as a background task, and has no visual representation. Like activities, services run on the main application process thread, but will usually spawn off other threads to run their tasks without affecting other applications running. The typical example for a service is a music player, where you play songs from your playlist while doing other things on your phone. Services extend the Service base class.
- Content Providers
A content provider is a custom API that allows read and write access to a certain data set. This then allows different applications to share data between each other. Content providers subclass the ContentProvider base class which provides a standard interface for accessing data. Applications will not call the ContentProvider implementation directly, but will instead go through the ContentResolver object, which can access any ContentProvider.
An intent is a specific action such as sending an email, playing a song or calling a contact.
The final piece of the application jigsaw is resources - images, text or non-coded information that you application needs to access or display.
The following diagram illustrates the different states for an Activity through it's lifecycle:
While you cannot control moving the activity between states, you will get notified as the state changes through the onX() methods like onStart(), onResume() etc. You can override these methods to get your application to react appropriately to these state changes.
Now that you have a better understanding of what makes up an Android application, we're ready to get going with some real development. The next article will bring you through your system setup.