Android Developer Meetup
-
Upload
medialets -
Category
Technology
-
view
1.201 -
download
1
description
Transcript of Android Developer Meetup
Build One, Ship to Many
March 3, 2010
Mike Novak, Medialets
Agenda
• Introduction• What's available to developers? • Quick overview of application components• Leveraging resources for multiple versions• Isolating new API features from older versions• Closing remarks• Questions
Introduction
Developer Resources:
• http://developer.android.com• Android Mailing Lists (Google Groups)• IRC (Internet Relay Chat) irc.freenode.net
o #android-dev - weekly office hours Thursday 8 PM Eastern / 5 PM Pacific
• For the curious... http://source.android.com
What's available to developers?
Android 2.0 Highlights• Accounts API• Bluetooth API• Contacts API
Android 2.1 Highlights• Live Wallpapers• Signal strength callback• Data connection callback
Complete release notes at http://developer.android.com/sdk
Why support Android 1.x?
*Note: Android 2.x support is starting to gain some ground on devices that shipped with 1.x
Quick Overview - App Layout
• assets/ - when you need raw byte access• bin/ - output of the project build• gen/ - Android generated classes• libs/ - external libraries to include• res/ - project resources (i.e. drawable, layouts) • AndroidManifest.xml - Application manifest• build.xml - Ant build script generated by the android
tool
Specifying Alternate Resources
• Many configuration options to limit resources for a specific version, device, screen, language, and input type.
• Tonight we will focus on the following:o Version specific resources for new SDK features.o Different screen pixel density configurations.
For more information: http://developer.android.com/guide/topics/resources/resources-i18n.html#AlternateResources
A Few Important Notes...
• Remember your target SDK version and min SDK version do not have to be the same.
• Creating a receiver for a 2.x intent will not break in 1.x, it just won't be executed.
• Using the `am` command on the device/emulator shell you can 'mock' a broadcast.
• Always test your app on all versions you support!
Initialization on Demand Holder
Credit: Josh Guilfoye - http://devtcg.org
• Is a lazy loading singleton.• Gives the ability to determine the proper class to
initialize at runtime.• This method is more elegant than reflection.• Reflection on the Dalvik VM is expensive.
Let's look at a sample...
Holder Sample Codepublic abstract class PlayerNotification { public static PlayerNotification getInstance() { if (Integer.parseInt(Build.VERSION.SDK) <= 4) return PreEclair.Holder.sInstance; else return EclairAndBeyond.Holder.sInstance; } public abstract void showNotification(Service context, int id, Notification notification); public abstract void hideNotification(Service context, int id);
private static class PreEclair extends PlayerNotification { ... }
private static class EclairAndBeyond extends PlayerNotification { ... }}
What to do about resources?
• Create graphics for each type of pixel density:o hdpi - currently the Droid and Nexus Oneo mdpi - the most common pixel density typeo ldpi - the tattoo, maybe more?
• dip/dp - Device Independent Pixels. 1dp is equivalent to 1px at 160dpi. mdpi is approx. equivalent to 160 dpi. hdpi = 240 and ldpi 120.
• Always extract strings from your source! Keeping strings in xml allows for easy localization!
Some Android Best Practices....
• Documentation has certainly improved recently• "premature optimization is the root of all evil." -
Donald Knuth• Prefer Virtual over Interface... calling through an
interface can take as much as 2x longer.• Use static methods if you aren't access the object's
fields.• Use the enhanced for loop cautiously... ok for
iterators .... not so good for ArrayLists.• Set private members to package level members
when accessing from an inner class.
Knuth, Donald. Structured Programming with go to Statements. Computing Surveys 6 (1974): 261–301
Some Numbers .....
Source: http://developer.android.com
Medialets Analytics SDK!
• Reports application runs, durations, custom events, and uncaught exceptions
• There's no cap on the amount of events that can be reported.
• See which versions of Android your users are running and on which devices.
• Enable location services for your application events.
• And its free!
http://www.medialets.com/blog/2010/03/01/medialets-releases-analytics-sdk-for-android-and-blackberry-applications/
Questions!
Twitter/IRC• michaelnovakjr
Blog: http://quietlycoding.com
My Info...