Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to listen to camera capture in Broadcastreceiver

Tags:

android

I saw many posts in StackOverflow regarding how to listen to camera events, and got few information but still there are few questions remain in my mind please let me know the answers for these:

I have an application which have a broadcast receiver and my broadcast receiver will lauch my activity, but the main purpose of having broadcast receiver is to listen to camera photo/video capture intent.

I want to know which is the intent i have to listen for this, and is it possible to do in this way.

thanks

like image 648
user954299 Avatar asked Dec 21 '22 08:12

user954299


1 Answers

For Receiving camera photo capture intent, try following code

public class CameraEventReciver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

       Toast.makeText(context, "New Photo Clicked", Toast.LENGTH_LONG).show();

    } 

and in manifest, register the receiver:-

<uses-permission android:name="android.permission.CAMERA" />

   <receiver
        android:name="com.android.application.CameraEventReciver"
        android:enabled="true" >
        <intent-filter>
            <action android:name="com.android.camera.NEW_PICTURE" />
            <data android:mimeType="image/*" />
        </intent-filter>
    </receiver>
like image 190
Rekha Avatar answered Dec 28 '22 09:12

Rekha