title: How to override (or at least listen to) bluetooth headset volume buttons on android?
body: <p>I would like to control my app with a headset keys (volume +, middle key, volume -).</p>
  
  <p>I have no problem detecting media keys:</p>
  
  <ul>
  <li>play/pause, triggered by click on middle</li>
  <li>next/previous, triggered by volume buttons long press</li>
  </ul>
  
  <p>I do have a problem detecting (and ideally intercepting) everything else. I am especially interested in volume keys.</p>
  
  <p><strong>!!</strong> Solutions with <strong>onKeyDown</strong> or listening to <strong>MEDIA_BUTTON</strong> or <strong>listening to volume changes</strong> (e.g. via AudioService) work with phone volume keys, but not with bluetooth volume keys <strong>!!</strong></p>
  
  <p>More info:
  (just as info) In activity on onKeyDown I do not see headset key presses (it only picks up clicks on phone volume rocker).</p>
  
  <p>I cannot infer clicks from volume changes, as there is no trigger if the device is at max/min volume. Also the volume dialog does not show up if I try to set above max volume with headset, as it does with phone volume buttons.</p>
  
  <p>In debugger, the only thing that happens upon vol+ on max volume is some action reported from avrcp in debug mode:</p>
  
  <pre><code>07:04:08.220 7106-7250/? I/BluetoothAvrcpServiceJni: btavrcp_volume_change_callback
  07:04:08.220 7106-30330/? V/Avrcp: MSG_NATIVE_REQ_VOLUME_CHANGE: volume=127 ctype=13
  07:04:08.281 5937-13180/? I/EDMNativeHelperService: isAVRCPProfileEnabled
  07:04:08.285 7106-7250/? I/BluetoothAvrcpServiceJni: btavrcp_volume_change_callback
  07:04:08.285 7106-30330/? V/Avrcp: MSG_NATIVE_REQ_VOLUME_CHANGE: volume=127 ctype=15
  </code></pre>
  
  <p>How could I get these events with my service? Or is there any useful alternative to detect such headset clicks?</p>