Hi, I'm trying to make an app that detects when a user takes a photo.
I set up a broadcast receiver class and registered it in the manifest
file by:

<receiver android:name="photoReceiver" >
  <intent-filter>
    <action android:name="com.android.camera.NEW_PICTURE"/>
      <data android:mimeType="image/*"/>
 </intent-filter>
</receiver>
No matter what I try to do the program won't receive the broadcast.
Here is my receiver class:

public class photoReceiver extends BroadcastReceiver {
  private static final String TAG = "photoReceiver";

@Override
public void onReceive(Context context, Intent intent) {
    CharSequence text = "caught it";
    int duration = Toast.LENGTH_LONG;
    Log.d(TAG, "Received new photo");

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
 }
}
If I remove the mimeType line in the manifest and in my activity I
send my own broadcast using

Intent intent = new Intent("com.android.camera.NEW_PICTURE");
sendBroadcast(intent);
then I successfully receive the broadcast and can see the log and
toast window. Am I approaching this the right way? Is there any thing
that I need to add? Thanks in advance for the help!

Also, the NEW_PICTURE is defined in the camera source, see a thread
here: stackoverflow.com/questions/3015448/…, when a picture is taken
it calls sendBroadcast(new Intent("com.android.camera.NEW_PICTURE",
mLastContentUri));

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to