简体   繁体   中英

Block hardware camera shutter / capture button Samsung Galaxy Camera on EK-GC200

I want to use my own camera modul at the Samsung Galaxy Camera EK-GC200. I can get a keycode for both buttons, but capture button always opens his own camera intent which then of course collapes with my own camera modul. Also zoom buttons always show some slide-popup when used.

Meanwhile I found some topics that some people were able to block the HOME button on their devices. But seems this is not usable for the camera buttons.

So is there any way to block the hardware buttons so at least the camera capture button doesn't open its own camera intent anymore ?

In your MainActivity.java (or some other activity), paste the following:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    Log.e(TAG, "keyCode: " + keyCode); // If you want to see the keycodes

    // If User hits the (physical) shutter button of the EK-GC200 camera
    if (KeyEvent.KEYCODE_FOCUS == keyCode || KeyEvent.KEYCODE_CAMERA == keyCode) {
        // Do nothing or start your own camera App
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

If you also want to intercept the return button, do:

if ((keyCode == KeyEvent.KEYCODE_BACK )) {
    // Upon return / back key:
    // Do NOT go to super.onKeyDown(keyCode, event);
    return true;
}

The HOME button can not be intercepted in this manner.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM