android.intent.action.CAMERA_BUTTON不广播上Desire Z的(升级Froyo)?action、intent、android、Froyo

2023-09-05 23:08:05 作者:墨染青衣颜

我也很难拦截的Desire Z的(升级Froyo)HW拍照键。我写了运行良好的G1(1.6),但不是在前面提到的手机样品。

I have hard time intercepting HW camera button on Desire Z (Froyo). I wrote a sample that runs fine on G1 (1.6) but not on aforementioned phone.

AndroidManifest.xml中

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.company" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".CameraReceiverTestActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <receiver android:enabled="true" android:exported="true"
        android:name=".CameraButtonReceiver">
        <intent-filter android:priority="999">
            <action android:name="android.intent.action.CAMERA_BUTTON" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>
</application>
</manifest>

和CameraButtonReceiver.java

And CameraButtonReceiver.java

package net.company;

public class CameraButtonReceiver extends BroadcastReceiver {
  static {
    Log.w("CBR", "onReceive clazz init");
  }

  @Override
  public void onReceive(Context context, Intent intent) {
      Log.w("CBR", "onReceive camera");
      abortBroadcast();
  }
}

在G1(1.6),我一看到这两个消息为preSS相机按钮和默认的摄像头应用程序是pssed燮$ P $。然而,Desire Z的(升级Froyo)没有这样的事情发生。玩优先级,code / XML声明后,我敢说这个手机发送这个广播与其他一些名字。

On G1 (1.6) I see both messages as soon as press the camera button and default camera app is suppressed. However, on Desire Z (Froyo) no such thing happens. After playing with priority, code/xml declarations I dare to say this phone sends this broadcast with some other name.

推荐答案

有一个设备制造商发送被点击时的拍照键,从我阅读的兼容性定义文档的任何广播没有任何要求。它可能只使用在欲望Z.前台活动我没有Z和因此无法确认你的测试。

There is no requirement for a device manufacturer to send any broadcast when the CAMERA button is clicked, from my reading of the Compatibility Definition Document. It might only be used by the foreground activity on the Desire Z. I don't have a Z and so cannot confirm your tests.

由于Android设备中的绝大多数没有摄像机按钮所有,你需要确保你的应用程序工作良好,没有这样的按钮,你提醒用户相机按钮可能会或可能不会与工作中的应用程序取决于设备。

Since the vast majority of Android devices do not have a CAMERA button at all, you will need to ensure that your app works well without such a button, and that you advise users that the CAMERA button may or may not work with your app depending upon device.