I am developing an Android application that requires an image be taken by the phone's camera. There should be tight integration between the application and the picture taking process. To achieve this, without having to write my own camera application component, I plan to use an Intent to leverage the phone's existing camera application.
The Android application framework features the concept of "Intents", or messages, that (in short), let one application use the services of another application. So, for example, my application can raise an Intent to use the already-existent Camera application which ships with most Android phones.
I tried out using the existing camera application via an Intent on a Nexus One, and it works pretty well. The user clicks a "Take Picture" button in my app, and then the Google-developed Camera app comes up. When the picture is taken, the camera goes away and my app re-appears. Pretty cool and rather seamless.
The major issue with Intents
Most Android OS'es are not pure and clean like that on a Nexus One. The Nexus One is like a clean room implementation of Android. In other words, the Android OS on most phones have likely been heavily modified by the hardware vendor (HTC, Motorola, for example), or the cell provider (Verizon, T-Mobile). If the camera app has been modified in some way, or outright replaced, and it does not conform to the Intent parameters (whether when calling or returning) that I developed against, then my app is hosed. This seems to be the case with the Camera application Intent with HTC and Motorola phones (see this bug and NOTE at end of this blog post). So, this Intent system is in place, but it only works if there is compliant receiver app of your Intent message.
The Intent I want to use:
android.provider.MediaStore.ACTION_IMAGE_CAPTURE
and a parameter (aka Extra) that the Intent takes:
android.provider.MediaStore.EXTRA_OUTPUT
However, it seems that the Camera application on the HTC and Motorola phones where those companies have modified the OS in a large way, the Intent really doesn't work as expected. So, what were left with is an "service" or API framework that isn't very reliable.
In the end, for me, it requires that I write my own Camera application component since I can't rely on the ACTION_IMAGE_CAPTURE Intent to behave the same on every Android phone that has a Camera application. Looking at it further, then, the openness of Android becomes a big pain in the ass that's not present on iPhones, because phone resellers and service providers are trashing the clean and pure OS that Google ships.
Note at end of this blog post
The bug I reference has to do with the Intent not returning the full-size image as taken by the camera, or even a reference to it. That itself is a big issue with this Intent, but it's not the core reason for this blog post. If you read throughout the bug text, several posters (like this one, shown below) state that the Intent doesn't even work as expected on certain HTC and Motorola phones. That's what I'm really writing about. The Intent system is nice, but there is no reliable contract that it will exist. If the Camera app was forever in the core OS and very unlikely to change, that Camera Intent would be reliable. Basically, you can't rely on Intents for apps not written by yourself or those which are not a permanent fixture, non-changing fixture in the OS.
A Key Post From the Bug
Comment 78 by russelljryan, Sep 15, 2010
johnyma22:
... snip ...
The bug was fixed in plain vanilla Android 2.0 (e.g. on an N1).
Part of the confusion is that the HTC Sense UI and the Samsung and Motorola custom UIs re-introduce this bug because they provide their own custom Camera application, which often times does not even accept the EXTRA_OUTPUT intent, and if it does, returns a tiny image as in Android 1.5.
As in Comment #64, barking at Google about this is pointless. The person you need to be hounding is the creator of the impaired UI that came with your phone.
As an Android developer, this is easily the worst part of Android.
No comments:
Post a Comment