0

I am Facing a problem and problem is I started service in activity, I used the below method in service class but its not working.

public boolean onKeyDown(int keyevent, keyEvent event) {
    if ((keyevent == KeyEvent.KEYCODE_VOLUME_DOWN)) {

        return true;
    }
    return onKeyDown(keyevent,event);

}

Shall I override keyevents in service class?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Ramakrishna
  • 68
  • 1
  • 1
  • 9

1 Answers1

0

Shall I override keyevents in service class?

No, because there is no onKeyDown() method in the Service class.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for reply. How can i override volumeup key event in service class?? – Ramakrishna Apr 17 '15 at 14:20
  • @Ramakrishna: AFAIK, that is not possible. – CommonsWare Apr 17 '15 at 14:25
  • I am trying to open flash light in keyevent_volume up which is called in service. Is there any other possiblities to open flash light app running in background. – Ramakrishna Apr 17 '15 at 14:32
  • @Ramakrishna: Bear in mind that not all Android devices have volume keys. There are some keys (and volume *might* be one of them) that trigger broadcasts -- take a look at the various broadcast actions defined on `Intent`. – CommonsWare Apr 17 '15 at 14:37