Detecting bluetooth 'call' button press

2019-05-15 01:58发布

I have a bluetooth headset which is able to communicate with my phone. It has one large 'call' button which answers/ends calls.

I am trying to make an app which will be able to intercept when the call button is pressed. I have tried using an intent filter:

<receiver android:name=".MediaButtonIntentReceiver">
    <intent-filter>
        <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>
</receiver>

but the call button does not appear to be classified as a media_button

any ideas on how I can achieve this? I would just like to know when the call button is pressed

2条回答
够拽才男人
2楼-- · 2019-05-15 02:11

try

android.intent.action.CALL_BUTTON

http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL_BUTTON

I'm not sure about it.. I think it fires for all call buttons, including any physical call buttons on the phone and buttons on the headsets .etc.

查看更多
SAY GOODBYE
3楼-- · 2019-05-15 02:15

If the button is currently bringing up the Voice Dialer (mine does), you want ACTION_VOICE_COMMAND. Add the following to your intent filter:

<action android:name="android.intent.action.VOICE_COMMAND" />
<category android:name="android.intent.category.DEFAULT" />
查看更多
登录 后发表回答