Replica of the 4.0.4 GDK code, but ported to KitKat