Android.intent.action.CAMERA_BUTTON not broadcasting on Desire Z (Froyo)?

I find it difficult to intercept the HW camera button on the Desire Z (Froyo). I wrote a sample that works fine on G1 (1.6), but not on the above phone.

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> 

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(); } } 

In G1 (1.6), I see both messages, as soon as they press the camera button and the default camera application is suppressed. However, this does not happen on Desire Z (Froyo). After playing with priority, code / xml declarations, I dare say that this phone sends this broadcast with some other name.

0
android camera broadcastreceiver android-2.2-froyo
source share
1 answer

It is not required that the device manufacturer send any broadcast when the CAMERA button is pressed from my reading of the compatibility definition document. It can only be used for the foreground work on Desire Z. I do not have Z and therefore cannot confirm your tests.

Since most Android devices do not have a CAMERA button at all, you will need to make sure that your application works without such a button, and that you advise users that the CAMERA button may or may not work with your application depending on the device.

0
source share

All Articles