I use a phone camera in an Android app to take a picture. I use Intents to use the built-in camera application, and I use the following code:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(FILEPATH)));
startActivityForResult(intent, ACTIVITY_NATIVE_CAMERA_AQUIRE);
It works great, and the camera is brought up. I can take a picture, and the phone presents me with three options: Cancel, Retry, OK. The first two works, clicking on cancel returns the user to the application, but pressing the OK button does not happen. Obviously, onActivityResult is not called, and the camera just stays on the screen. Nothing in the debugger either.
Launching the app on the Nexus One with Android 2.2.1. The same problem on an emulator running Android 2.0.
Edit: tested on HTC Desire running Android 2.2 with the HTC Sense user interface: works great. Nothing in emalator and Google N1.
Edit2: It seems that active work with the HTC Desire image works better in the sense that it returns, but does not take into account the EXTRA_OUTPUT setting and returns only a small image in onActivityResult -call. Check on the ddms console, when the phone is connected to the computer, I see that the phone saves the image on the SD card, but the path does not return back to my application. It starts to look like there is no reliable way to use the camera’s intent and return a reasonable size image. Bad, bad, bad.
source
share