Android: BroadcastReceiver intent to Detect Camera Photo Taken?

前端 未结 3 1273
感动是毒
感动是毒 2020-11-30 05:01

I\'m working on an Android application which needs to perform an action each time a new image is taken with the phone. I don\'t want to take the image within my application

相关标签:
3条回答
  • 2020-11-30 05:38

    Quite an old question, if anyone still needs the solution try using

    android.hardware.action.NEW_PICTURE

    as your intent filter

    <!-- Receiver for camera clicks -->
        <receiver
            android:name=".receivers.CameraEventReceiver"
            android:label="CameraEventReceiver">
            <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>
    

    It will return the Uri of the image in intent.getData() of its onReceive() function

    Hope it helps

    0 讨论(0)
  • 2020-11-30 05:44

    try this one this works for me

    <receiver android:name=".pictureReceiver" >
            <intent-filter android:priority="10000" >
                <action android:name="android.intent.action.CAMERA_BUTTON" />
    
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
    </receiver>
    
    0 讨论(0)
  • 2020-11-30 05:48

    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.

    0 讨论(0)
提交回复
热议问题