Question

I have a requirement in my app where I have to select various buttons like Search, Volume Up, Volume Down, Back buttons to launch my app.

enter image description here

I know that I have to override the functionality of the these buttons but what API do I have to use and exactly how can I override them.

No correct solution

OTHER TIPS

Your application should be running and you need this code:

public boolean onKeyDown(int keyCode, KeyEvent event) 
{ 
   if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { 
       // Do your thing 
       return true;
   } else {
       return super.onKeyDown(keyCode, event); 
   }
}

List of keys: http://developer.android.com/reference/android/view/KeyEvent.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top