android.hardware.action.NEW_PICTURE is fired twice
android, broadcastreceiver
Solution
The stock Camera app on KitKat send both `android.hardware.action.NEW_PICTURE` and `com.android.camera.NEW_PICTURE` broadcasts (don't know for older versions), that may be why your receiver is notified twice.
If your app is only for ICS+ you can remove `com.android.camera.NEW_PICTURE` from your intent filter as it is not documented.
If you still want to handle this, your receiver should implement some logic to know the intent has already been handled for the data it receives. This logic depends on your application and what you do with the received data.
Problem
I am trying to "listen" when a user take picture using the default camera app. I used the broadcast receiver solution as below Manifest: ``` <receiver android:name=".CameraEventReceiver" android:enabled="true" > <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> ``` The receiver: ``` public class CameraEventReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Cursor cursor = context.getContentResolver().query(intent.getData(), null,null, null, null); cursor.moveToFirst(); String image_path = cursor.getString(cursor.getColumnIndex("_data")); Toast.makeText(context, "New Photo is Saved as : -" + image_path, Toast.LENGTH_SHORT).show(); Intent i = new Intent(context, MyAct.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } ``` The problem is that the event is fired multiple times (twice). My breakpoint at where `context.startActivity(i)` is called twice and both with the action `android.hardware.action.NEW_PICTURE`. Any reason why this is happening or how to prevent it? Thank you