A few months ago I setup an Android development environment and afterwards never did anything with it. Well I finally have access to Android hardware and thought this would be a good time to pick it up again. Before starting up the compiler and writing a "Hello World" application I thought I would first review Android terminology (from a developer's perspective) and familiarize myself with the components of an application.
- Activities - Activities are pretty much the same as what a typical person would refer to as an application. Activities typically have user interfaces. It's possible to make an activity with no user interface. But if you are doing that you would typically use a service.
- Content Provider - Think of a content provider as a package for making information available to another application. They abstract data away in a form that is accessible by other applications.
- Intent - an intent is the same as what some might call an event or message under other platforms. Intents tell applications of events such as hardware insertion or removal, application starts, when the location of the phone changes by a certain distance, and so on. In addition to predefined intents you can also create your own intents.
- Service - Services are a type of background process. They have no user interface and run quietly in the background performing their work.
When you are creating an Android project a specific directory structure is used. Here is a breakdown of a typical Android application and the meaning/purpose of each file or directory.
- AndroidManifest.xml - Describes the application being built.
- build.xml - Ant script for compiling the application
- default.properties - script used by the ant script
- bin/ - contains the compiled application
- libs/ - holds third party code libraries
- src/ - holds the Java source code for the application
- res/ - holds resources for the application. Contains subfolders for resource type.
- assets/ - holds other static files to be packaged with the application
The resource folder (res/) contains subfolders for further organizing resources. It's structure looks like the following:
- /res/drawable/ - for images
- /res/layout/ - for XML based UI
- /res/menu/ - menu layout
- /res/raw/ - misc files
- /res/values/ - strings and other values
- /res/xml/ - XML files included with the application
When you build your application there are four items of outbut in the /bin folder.
- /bin/classes/ - the compiled Java classes
- /bin/classes.dex - the DEX executable from the compiled Java classes (DEX is deserving of a post of its own)
- /bin/myApp.ap_ - applications resources packaged as a zip file
- /bin/myApp-debug.apk or /bin/myApp-unsigned.apk - The actual application