Android: Broadcastreceiver Intent to Detect Camera Photo Taken

Android: BroadcastReceiver intent to Detect Camera Photo Taken?

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.

How to get camera click event with the help of broadcast receiver?

I solved the ClassNotFoundException by making the CameraReceiver class public. I implemented your code on my android project, and got the ClassNotFoundException but i solved it now. Just change your class as following and also change the first parameter of Toast as I did in the following code.

public class CameraReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
abortBroadcast();
Log.d("New Photo Clicked", ">");
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,
1000).show();
}

}

and it should work, it is working for me, when I take picture from camera. Remove the class from MainActivity and create a separate public CameraReceiver class for above code.



Related Topics



Leave a reply



Submit