The Airsource Blog

Articles in the Android category

Bound services and retained fragments

Getting background tasks right is important. We want our UIs to remain responsive while the background task does its thing. Here I'm going to focus on Android's 'bound services' and a neat pattern for getting background work done on some shared resource, such as an internet connection and ... Read more…

Androidinous Efficiency: To bool or not to bool?

A common belief among programmers is that you should write code that says what you mean, because the compiler will probably do a better job at optimising than you can do off the top of your head. On the other hand, Writing Efficient Android Code says "It is unwise to rely on a compiler to "save" you and make your code fast enough" and recommends that programmers do things like caching member variables (like array lengths) in local variables. This isn't just premature optimisation; it's trivial stuff we expect the most basic compilers to handle! To understand why, it helps to know how your code ends up running on device: Read more…

Androidinous Intentions

So you've acquired an Android Dev Phone 1 (the page goes to great lengths to avoid telling you that it's just an unlocked G1). You've downloaded Eclipse, installed the Android plugin, and created a "MyProject" app that says "Hello World, MyProject". Now what? Well, if you've been paying attention, you'll have heard of two (or three) new paradigms: Tasks correspond vaguely to the user's idea of accomplishing something, like "sending an e-mail", and an associated "activity stack" which is hidden from the programmer. Activities correspond loosely to subtasks, like "picking a contact". Intents are issued by activities (like SendEmailActivity) to launch other activities (like ContactPickerActivity). But that's about it. UI programming is traditionally a pain, which is why I like the iPhone SDK's InterfaceBuilder -- Read more…