应用程序不接收广播的被打开相机 [英] Application is not receiving broadcast for camera being opened

查看:203
本文介绍了应用程序不接收广播的被打开相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想收到广播的被打开相机。我想如果某些条件为真阻止这一进程。

我没有得到被打开相机播出。 (我可以播出拍摄,这是不是我想要的新照片。)

这是我的一块manifest文件:

 <接收
            机器人:名字=。HardwareActionListener
            机器人:启用=真
            机器人:出口=真正的>
            <意向过滤器的android:优先=1000>
                <作用机器人:名字=android.intent.action.CAMERA_BUTTON>
                < /作用>
            &所述; /意图滤光器>
< /接收器>

这是我的一块文件HardwareActionListener.java的

 的System.out.println(意图的行动:+ intent.getAction());如果(intent.getAction()。equalsIgnoreCase(
                android.intent.action.CAMERA_BUTTON)){
            的System.out.println(拍照键广播接收并中止);
            如果(some_condition_true)
                  abortBroadcast();
        }

我已搜查谷歌和stackverflow为此一整天。而且我想每一个组合。
但我没有得到被打开相机播出。

我使用的三星Galaxy Tab进行测试。这是不是有硬件相机按钮。

而在<一个答案href=\"http://stackoverflow.com/questions/5960663/how-to-listen-android-intent-action-camera-button-broadcast-action-in-android\">this问题说,


  

您不能:意图仅由硬件拍照键生成,
  不是由一个摄像头应用程序中的按钮。


那么,有什么不对,我manifest文件的意图过滤器?或者是它的问题,由于设备没有硬件拍照键?


解决方案

  

我要接收被打开相机广播。


有没有这样的广播。


  

我想如果某些条件为真阻止这一进程。


请使用设备管理员API来控制访问摄像头。


  

这是我的一块manifest文件


您正在收听相机按钮presses,这可能会或可能不会有什么用相机应用程序,也不要在所有设备上存在。


  

但我没有得到的被打开相机播出。


这是因为不存在这样的广播


  

而在这个问题一个答案说,你不能:意图仅由硬件拍照键生成的,而不是由一个摄像头应用程序中的按钮


这答案是正确的。

I want to receive a broadcast for camera being opened. I want to block that process if some condition is true.

I am not getting broadcast for camera being opened. (I can get broadcast for new picture taken, which is not what I want.)

This is a piece of my manifest file:

<receiver
            android:name=".HardwareActionListener"
            android:enabled="true"
            android:exported="true" >
            <intent-filter android:priority="1000" >
                <action android:name="android.intent.action.CAMERA_BUTTON" >
                </action>
            </intent-filter>
</receiver>

This is a piece of my file HardwareActionListener.java

System.out.println("Intent action: " + intent.getAction());

if (intent.getAction().equalsIgnoreCase(
                "android.intent.action.CAMERA_BUTTON")) {
            System.out.println("CAMERA Button broadcast received and aborted");
            if(some_condition_true)
                  abortBroadcast();
        }

I have searched on google and stackverflow for this for a whole day. And I tried each and every combination. But I am not getting broadcast for camera being opened.

I am using Samsung Galaxy tab for testing. Which is not having hardware Camera button.

And one answer in this question says that

You can't: the intent is only generated by the hardware camera button, not by the button within a camera app.

So is there anything wrong in my manifest file's intent filter? Or is it the problem due to device not having hardware camera button?

解决方案

I want to receive a broadcast for camera being opened.

There is no such broadcast.

I want to block that process if some condition is true.

Please use the device admin APIs to control access to the camera.

This is a piece of my manifest file

You are listening for CAMERA button presses, which may or may not have anything to do with a camera app, and do not exist on all devices.

But I am not getting broadcast for camera being opened.

That is because there is no such broadcast.

And one answer in this question says that "You can't: the intent is only generated by the hardware camera button, not by the button within a camera app."

That answer is correct.

这篇关于应用程序不接收广播的被打开相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆