Android: BroadcastReceiver intent to Detect Camera Photo Taken?

﹥>﹥吖頭↗ 提交于 2019-11-27 04:08:06

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.

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

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!