How to capture key events from bluetooth headset with android

前端 未结 3 1581
夕颜
夕颜 2020-12-01 01:42

My app can be controlled by normal headset. It simply overrides \"onKeyDown\". But key events from bluetooth headset are not captured - why? Or how to capture bluetooth key

3条回答
  •  时光说笑
    2020-12-01 02:28

    If you are trying to listen for this from an activity, use onKeyDown() and catch the KEYCODE_MEDIA_PLAY_PAUSE (KEYCODE_MEDIA_PLAY and KEYCODE_MEDIA_PAUSE post ICS) key events.

    Also for the broadcast receiver solution to work make sure there arent other apps installed and running in the background that catch these events which might take priority over yours.

    Also look at this: Android - registering a headset button click with BroadcastReceiver

提交回复
热议问题