سؤال

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.

لا يوجد حل صحيح

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top