I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

Android 101: The Basics

10.04.2010
| 14738 views |
  • submit to reddit

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: 

  • Activities
    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.
  • Services
    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.
  • Intents
    An intent is a specific action such as sending an email, playing a song or calling a contact.
  • Resources
    The final piece of the application jigsaw is resources - images, text or non-coded information that you application needs to access or display. 

Activity Lifecycle

 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. 

Next Up

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. 

 

Tags:

Comments

Jason Kilgrow replied on Tue, 2010/10/05 - 10:06am

Great post! Thanks very much!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.