Shaun Abram
Technology and Leadership Blog
SF JUG: Android UIs
There was another great San Francisco JUG meeting tonight down at the Google offices. It was all very well organized as usual by Sasa. The speaker was Romain Guy from Google’s Android UI team. He gave his talk from Google IO: Turbo-charge your UI: How to Make your Android UI Fast and Efficient.
The presentation slides can be found here.
I thought Romain was an excellent presenter and did a top job of talking on his area of expertise: Android UI development. He covered the issues you need to be aware of when developing Android UIs if you want them to be performant, best practices and work-arounds for the gotchas, as well as useful tools that can be used for development. Personally, I would have benefited from more of a broad overview and introduction to Android, but that is more a reflection of my own lack of knowledge on Android! Maybe the newly created Android User Group will provide an ‘Intro To’ type talk at some point…
First, Romain covered the Andriod UI terminology (like Canvas, Drawable, Surfaces and Views) before covering the architecture.
The bulk of his talk covered how to make sure you UI runs fast, including:
- Avoiding runtime scaling of background images
- Avoiding invalidating (i.e. redrawing) the entire screen and instead only invalidate the small part of the screen that has actually changed.
- Minimizing the number of views you use (ideally have <100, which seems pretty reasonable for a tiny phone screen!) and talked about some techniques to help with this including using ViewStubs and recycling views
- Avoid allocating memory (apparently the Garbage Collector is slow and pretty much stops the world when it is running)
- Use SoftReferences (objects that only have soft references to them will be kicked out of memory if the Garbage Collector needs more memory) and WeakReferences (which can help to avoid memory leaks) when possible
He also talked about some neat dev and debug tools including Allocation Tracker (which monitors objects being created, memory being allocated etc) and Hierarchy Viewer (which shows you all the devices/windows/views you have how long things are taking to render).
He also mentioned the Android emulator that can be used for testing your apps.
Some of the questions from the Q&A session included:
Q: Will Android support languages other than Java?
A: Romain mentioned that there is a version of Scala and python that work on Android, but currently all APIs are in Java.
Q: Does Flash work on Android?
A: Development is on-going and the Android team is working with Adobe.
(I found more on the web about this topic here: http://gizmodo.com/5300800/flash-for-android-webos-landing-in-october)
Q: Can JavaFX be used on Android?
A: Code might be hard to run on the phone and may not be performant.
Q: Apparently, Sony Ericsson are also building an Android phone. How do you plan to avoid fragmentation as other companies start shipping Android phones?
A: CTS – Compatibility Test Suite
You cant ship a phone as ‘Android’ if it doesn’t pass the CTS.
Other links:
http://d.andriod.com
source.android.com
android.git.kernel.org
code.google.com/p/apps-for-andriod
http://android-developers.blogspot.com/
http://forum.xda-developers.com/