0

I'm like working on an app that will call home when I press down the volume.

I have a working Dial / Call method. Now I need help figuring out how to get it all encapsulated in a method that will activate when the volume key down is pressed and held.

Any advice would help immensely.

Jake1164
  • 12,291
  • 6
  • 47
  • 64
a.kollar
  • 43
  • 6
  • See http://stackoverflow.com/questions/6896746/android-is-there-a-broadcast-action-for-volume-changes – Tim Jul 01 '12 at 17:25

1 Answers1

1

You need to use the onKeyLongPress() method to capture this event, something like this:

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 
    {
        //Your Code here
        return true;
    }
    return super.onKeyLongPress(keyCode, event);
}

This only captures the Volum down event, and passes everything else on back to it's normal implentation.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195