dispatchKeyEvent onKeyDown

@Override
    public boolean dispatchKeyEvent(KeyEvent event) {
    	 int action = event.getAction(); 
         int keyCode = event.getKeyCode(); 
             switch (keyCode) { 
             case KeyEvent.KEYCODE_VOLUME_UP: 
                 if (action == KeyEvent.ACTION_UP) {                  
                	 Log.e(TAG, "KEYCODE_VOLUME_UP ");
                 } 
                 return true; 
             case KeyEvent.KEYCODE_VOLUME_DOWN: 
                 if (action == KeyEvent.ACTION_UP) { 
                	 Log.e(TAG, "KEYCODE_VOLUME_DOWN ");
                 } 
                 return true; 
             default: 
                 return super.dispatchKeyEvent(event); 
             } 
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    	// TODO Auto-generated method stub
    	Log.e(TAG, "onKeyDown");
    	Log.e(TAG, "keyCode -- "+ keyCode);
    	Log.e(TAG, "event -- " + event.getAction());
    	return super.onKeyDown(keyCode, event);
    }


你可能感兴趣的:(dispatchKeyEvent onKeyDown)