Enhanced to work in Android 2.2 (API level 8).