views:

464

answers:

0

Hi

Samsung Galaxy, Android 1.5. I'm trying to detect when the user releases the camera button. I have a receiver that gets the ACTION_CAMERA_BUTTON intent and examines the EXTRA_KEY_EVENT that comes with it,using the following code (in the onReceive() in the receiver)

@Override
public void onReceive(Context context, Intent intent) {
    String intent_action = intent.getAction(); 
     if (intent_action.equals(Intent.ACTION_CAMERA_BUTTON) ) {
                abortBroadcast();
                KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

            if ( key.getAction() == KeyEvent.ACTION_DOWN )
                Toast.makeText(context, "press", Toast.LENGTH_SHORT).show();
            else if ( key.getAction() == KeyEvent.ACTION_UP )
                Toast.makeText(context, "release", Toast.LENGTH_SHORT).show();
            else if ( key.getAction() == KeyEvent.ACTION_MULTIPLE )
                Toast.makeText(context, "multi", Toast.LENGTH_SHORT).show();
    }
}

When I press the button, I only get the "press" popup.

Is this a limitation in the phone or in Android? Is there another way to detect the release of the camera key?