Getting Xcode static libraries to work

Getting Xcode static library dependencies to work is way harder than it should be! This weekend I setup a new Xcode OS X workspace with 2 child projects. One project was the app and the other a static library used by the app. Setting the static library as a dependency of the app project took ages. Part of the reason was my lack of knowledge but Xcode should really give a bit more help. Continue reading

Using AndroVM

Update: the team behind AndroVM have released Genymotion. It greatly simplifies the downloading of device images and automatically connects them to adb.

AndroVM is a novel alternative to the Android emulator with Android running in a virtual machine (VM) using VirtualBox. It works quite well and for some requirements can be significantly faster than the Android emulator. Continue reading

Custom drawable states in Android

A state list drawable is a really useful Android resource for displaying different drawables for a view depending on the state of that view. e.g. we can define a state list drawable for the background of a button that defines a colour for both pressed and unpressed states. The button takes care of switching between the two drawables depending on the state.

You can make state list drawables even more useful by defining custom states. Continue reading

Android screen utility class

There are a few common operations I infrequently perform related to the Android screen:

  • Converting a pixels value to the corresponding density independent pixels (DIP) value and vice versa
  • Getting the screen dimensions
  • Checking what orientation the device is in
  • Getting the screen size (small, normal, large, extra-large)

They’re not difficult but it is annoying having to remember exactly how they’re done so I created a utility class to make it a bit easier. Continue reading

Views saving instance state in Android

The activity lifecycle is central to Android development. Although it is quite well defined, it does take a bit of getting used to. One aspect new developers perhaps struggle with is that rotating the device will by default destroy and recreate the activity.

A well behaved activity will restore its state after a rotation so the user can continue using the application with no lose of state. e.g. EditText widgets should restore the text they contained when the device was rotated and a long running operation should resume without restarting. Continue reading

BugSense setup on Android

We started using BugSense at work recently to log uncaught exceptions in our Android applications. It works really well and is very easy to setup, best of all it’s free!

The setup instructions say to call BugSenseHandler.setup() in your “main/first activity” but we found that calling this method in the subclassed Application.onCreate() method also works and is better if your application has more than one entry point.

The complete setup instructions can be found here.