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.
android camera broadcastreceiver android-2.2-froyo
zeratul021
source share