I’m working on an Android application which needs to perform an action each time a new image is taken with the phone. I don’t want to take the image within my application, but rather perform some action when the Camera app takes an image and saves it to the SD card. Right now, I’ve gotten a BroadcastReceiver implemented that’s currently listening for “android.intent.action.CAMERA_BUTTON”. However, this doesn’t seem to get called when I’m wanting it to. I’ve tried to debug the application on my own phone with a linebreak on the first line of the BroadcastReceiver’s OnReceive method, but it never reaches that code.
Does anyone know what the correct intent for which I should be listening is? Or is using a BroadcastReceiver not even the best way to do this? (For example, is there a better way to accomplish this such as listening for when a new image is saved to the card)?
Update: I do have a Trackball on my phone (HTC Eris), so is it possible that taking photos that way doesn’t get sent as “Camera Button”? If so, is there a workaround for a phone without a “Camera Button”, but rather something like a Trackball?
Right now, I’ve gotten a BroadcastReceiver implemented that’s currently listening for “android.intent.action.CAMERA_BUTTON”. However, this doesn’t seem to get called when I’m wanting it to.
That only gets broadcast if the foreground activity does not consume the event.
Quite an old question, if anyone still needs the solution try using
as your intent filter
<!-- Receiver for camera clicks --> <receiver android:name=".receivers.CameraEventReceiver" android:label="CameraEventReceiver"> <intent-filter> <!-- <action android:name="com.android.camera.NEW_PICTURE" /> --> <action android:name="android.hardware.action.NEW_PICTURE" /> <data android:mimeType="image/*" /> </intent-filter> </receiver>
It will return the Uri of the image in intent.getData() of its onReceive() function
Hope it helps
try this one this works for me
<receiver android:name=".pictureReceiver" > <intent-filter android:priority="10000" > <action android:name="android.intent.action.CAMERA_BUTTON" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver>