2012-06-21 69 views
3

我有一個藍牙耳機,可以與我的手機通信。它有一個大的「呼叫」按鈕,可以接聽/結束通話。檢測藍牙「通話」按鈕按

我試圖做一個應用程序,它將能夠攔截通話按鈕時按下。

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

但呼叫按鈕不會出現被列爲media_button

我如何能做到這一點任何想法:我一直在使用一個意圖過濾試過嗎?我只是想知道,當呼叫按鈕被按下

+0

你看過這個答案:http://stackoverflow.com/a/10147953/1267661? – Sam

+0

是的,沒有幫助不幸。我可以使用該代碼檢測來自有線耳機的「播放」按鈕,但不能從我的藍牙中檢測到 –

回答

0

如果該按鈕目前正在啓動語音撥號器(我的),你想要ACTION_VOICE_COMMAND。添加以下內容到你的意圖過濾器:

<action android:name="android.intent.action.VOICE_COMMAND" /> 
<category android:name="android.intent.category.DEFAULT" /> 
+0

然後,我會如何在我的代碼中使用它?例如回調函數? – Adam

+0

@Adam Google for「android BroadcastReceiver」 –

+0

@chrispy看到我的問題[這裏](http://stackoverflow.com/questions/43274868/detecting-bluetooth-headset-call-button-press-in-android) – ADM