2013-03-27 88 views

回答

0

您使用的是BroadcastReceiver嗎?我猜你是。

從Android開發人員:

public void onReceive(Context context, Intent intent) { 
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { 
     //receive the key press event 
     KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); 
     //check the keypress 
     if (KeyEvent.**** == event.getKeyCode()) { 
      // Handle key press. 
     } 
    } 
    } 
} 

** a link with various keypress codes