Fix Android 2.2 compatibility

Same as #124, but for the 2.3 branch.