开发者

Broadcast receiver for ACTION_UP of the camera button in android

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜