A util project to take pictures on Android devices utilizing the camera intent.
It seems to be the simplest thing in the world: taking a picture within your Android app using the default camera activity. However, there are many pitfalls which are covered in several posts across the web as, for instance, null intents being passed back, the orientation of the picture not being correct or OutOfMemoryErrors. Finally, I managed to get it working on a wide variety of devices (see list below) and I wanted to share my solution with you. The code is partially based on the following posts:
I tried hard to avoid implementing different strategies based on the device configuration (e.g. manufacturer, model, ...). Unfortunately, I did not get around it. Going through hundreds of posts and talking to several developers, nobody found a solution that works on all devices without implementing device configuration specific code.
Please feel free to check out the code and test it on your devices. The CameraIntentHelper class provides the main functionality.
CameraIntentActivity within the sample package is an example Activity on how to implement the CameraIntentHelper. CameraIntentFragment held by the ParentActivity showcases the CameraIntentHelper implementation within a Fragment.
The code was successfully tested on the following devices with Android API-Level >= 8 and stock Android.
With regards to custom Roms, the code was successfully tested on the following devices with Android API-Level >= 8 and the CyanogenMod.