Modified for Android API 8 and much more...