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
Android Repeat Action on Pressing and Holding a Button
How to Access an Image from the Phone's Photo Gallery
Google Geocoder Service Is Unavaliable (Coordinates to Address)
How to Delete Internal Storage File in Android
Android Multidex Support Library Using Eclipse
Custom Title Bar Without Padding (Android)
How to Dynamically Change an App Icon Like Calendar App Does
How to Set Searchview Textsize
Android Audiotrack Playing .Wav File, Getting Only White Noise
Android Gridview Keep Item Selected
How to Pass Arraylist<Hashmap<String, String>>From One Activity to Another
Floatingactionbutton Doesn't Hide
Syncing Android Studio Project with Gradle Files
Android Error - Caused By: Java.Lang.Noclassdeffounderror: Android.Support.V4.Util.Sparsearraycompat