An Introduction to Android Development
Ask ALL THE QUESTIONS!
Where I'm Returning
My Industry Experience
- May 2001: I start working in the field. Gas averages $1.67/gallon.
- March 2012: I'm still working in the field. Gas averages $3.92/gallon.
- I've been doing this a long time.
- Gas prices suuuuuuuuuuck.
Bird's Eye View of Android
- Android SDK using Java
- Android SDK using an embedded interpreter
- Titanium, PhoneGap, etc.
Android SDK + Java
- Pros: It's the beaten (read: supported) path
- Cons: It's Java and the supported IDE is Eclipse
- Side note: Android uses (and in some cases extends) Apache Harmony for its Java class libraries
Android SDK + Interpreter
- Accomplished via SL4A
- Pros: Languages are less painful, may already be in your skill set
- Cons: Support isn't native, may result in some performance loss
- Development platform produced by Appcelerator
- Pros: Uses HTML5/CSS/JS; same codebase can be deployed to Android, iOS, and Blackberry with near-native performance
- Cons: Some performance loss from using an interpreter; middleware introduces another layer for bugs and reliance on a third party vendor
- Development platform produced by Nitobi
- Later acquired by Adobe and incubated as Apache Cordova
- Pros: Native mobile app dev with HTML5/CSS/JS; can be deployed to Android, iOS, Blackberry, Windows Mobile, webOS, and others
- Cons: Basically the same as Titanium
Path of Least Resistance
- Start with Android SDK + Java
- Download and install 3 (maybe 4) things:
Warning: Huge Docs
- Docs for Android are great, but massive
- Try not to be overwhelmed or discouraged by this
- This will (to some extent) pass once you've gotten your hands dirty
The classic "Hello World" example introduces a number of basic concepts:
- Creating a new Android project
- A basic Activity Java class
- Controlling and localizing the UI using XML layout files
- Running the project in a local emulator in normal and debug modes
- From Application Fundamentals: "An activity presents a visual user interface for one focused endeavor the user can undertake."
- Activities function as windows or "screens" that can gain focus and contain the components of the UI to present to the user
- A main activity serves as the entry point to the application
Views and Layouts
- From the Hello World tutorial: "A View is a drawable object used as an element in your UI layout, such as a button, image, or... a text label."
- Views are organized into layouts, which are covered in the Hello, Views tutorial - RelativeLayout is a commonly used one
- Layout can be controlled programmatically, but the more common approach is using a separate XML file
- From Intents and Intent Filters: "Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents."
- In particular, intents are used to start one activity from another and can also function as hash maps for passing custom parameters between activities
- These are used for the application icon, if nothing else in your project
- PNG is the preferred format
- Alternate versions of resources can be provided for different screen densities, screen orientations, and locales
- Applications can't be installed if they aren't signed
- During development, signing can be done in debug mode (which Eclipse does automatically by default)
- For distribution, signing must be done in release mode using a private key
- Private key is used to publish the application to Google Play
Publishing applications to Google Play also requires providing two versions:
- versionCode: positive integer for update detection (e.g. 42 updates 41)
- versionName: string displayed to the user (e.g. 1.2.3)
- Warning: I haven't used this feature, take this with a grain of salt
- Licensing can be used to query Google Play for the licensing status of the current user and restrict application access as appropriate
- Licensing status data is made available to the application after access is granted so further custom constraints can be applied
- Licensing API only applies to paid applications hosted in Google Play
- In order to be published, an application must:
- be signed with a private key
- have proper versions defined
- have a defined icon and label
- One-time $25 fee gives you access to publish applications to Google Play
- Upload the built signed APK file and provide some metadata
- Application becomes available in Google Play fairly shortly once it's posted