Example usage for android.view KeyEvent KEYCODE_CAMERA

List of usage examples for android.view KeyEvent KEYCODE_CAMERA

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_CAMERA.

Prototype

int KEYCODE_CAMERA

To view the source code for android.view KeyEvent KEYCODE_CAMERA.

Click Source Link

Document

Key code constant: Camera key.

Usage

From source file:Main.java

public static String getKeyNameByCode(int code) {
    switch (code) {
    case KeyEvent.KEYCODE_0:
        return "<0>";
    case KeyEvent.KEYCODE_1:
        return "<1>";
    case KeyEvent.KEYCODE_2:
        return "<2>";
    case KeyEvent.KEYCODE_3:
        return "<3>";
    case KeyEvent.KEYCODE_4:
        return "<4>";
    case KeyEvent.KEYCODE_5:
        return "<5>";
    case KeyEvent.KEYCODE_6:
        return "<6>";
    case KeyEvent.KEYCODE_7:
        return "<7>";
    case KeyEvent.KEYCODE_8:
        return "<8>";
    case KeyEvent.KEYCODE_9:
        return "<9>";
    case KeyEvent.KEYCODE_A:
        return "<A>";
    case KeyEvent.KEYCODE_B:
        return "<B>";
    case KeyEvent.KEYCODE_C:
        return "<C>";
    case KeyEvent.KEYCODE_D:
        return "<D>";
    case KeyEvent.KEYCODE_E:
        return "<E>";
    case KeyEvent.KEYCODE_F:
        return "<F>";
    case KeyEvent.KEYCODE_G:
        return "<G>";
    case KeyEvent.KEYCODE_H:
        return "<H>";
    case KeyEvent.KEYCODE_I:
        return "<I>";
    case KeyEvent.KEYCODE_J:
        return "<J>";
    case KeyEvent.KEYCODE_K:
        return "<K>";
    case KeyEvent.KEYCODE_L:
        return "<L>";
    case KeyEvent.KEYCODE_M:
        return "<M>";
    case KeyEvent.KEYCODE_N:
        return "<N>";
    case KeyEvent.KEYCODE_O:
        return "<O>";
    case KeyEvent.KEYCODE_P:
        return "<P>";
    case KeyEvent.KEYCODE_Q:
        return "<Q>";
    case KeyEvent.KEYCODE_R:
        return "<R>";
    case KeyEvent.KEYCODE_S:
        return "<S>";
    case KeyEvent.KEYCODE_T:
        return "<T>";
    case KeyEvent.KEYCODE_U:
        return "<U>";
    case KeyEvent.KEYCODE_V:
        return "<V>";
    case KeyEvent.KEYCODE_W:
        return "<W>";
    case KeyEvent.KEYCODE_X:
        return "<X>";
    case KeyEvent.KEYCODE_Y:
        return "<Y>";
    case KeyEvent.KEYCODE_Z:
        return "<Z>";
    case KeyEvent.KEYCODE_APOSTROPHE:
        return "<'>";
    case KeyEvent.KEYCODE_AT:
        return "<@>";
    case KeyEvent.KEYCODE_BACK:
        return "<Back>";
    case KeyEvent.KEYCODE_BACKSLASH:
        return "<\\>";
    case KeyEvent.KEYCODE_CALL:
        return "<Call>";
    case KeyEvent.KEYCODE_CAMERA:
        return "<Camera>";
    case KeyEvent.KEYCODE_CLEAR:
        return "<Clear>";
    case KeyEvent.KEYCODE_COMMA:
        return "<,>";
    case KeyEvent.KEYCODE_DEL:
        return "<Del>";
    case KeyEvent.KEYCODE_DPAD_CENTER:
        return "<PadCenter>";
    case KeyEvent.KEYCODE_DPAD_DOWN:
        return "<PadDown>";
    case KeyEvent.KEYCODE_DPAD_LEFT:
        return "<PadLeft>";
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        return "<PadRight>";
    case KeyEvent.KEYCODE_DPAD_UP:
        return "<PadUp>";
    case KeyEvent.KEYCODE_ENDCALL:
        return "<EndCall>";
    case KeyEvent.KEYCODE_ENTER:
        return "<Enter>";
    case KeyEvent.KEYCODE_ENVELOPE:
        return "<Envelope>";
    case KeyEvent.KEYCODE_EQUALS:
        return "<=>";
    case KeyEvent.KEYCODE_EXPLORER:
        return "<Explorer>";
    case KeyEvent.KEYCODE_FOCUS:
        return "<??? 0>";
    case KeyEvent.KEYCODE_GRAVE:
        return "<??? 1>";
    case KeyEvent.KEYCODE_HEADSETHOOK:
        return "<??? 2>";
    case KeyEvent.KEYCODE_HOME:
        return "<Home>";
    case KeyEvent.KEYCODE_LEFT_BRACKET:
        return "<(>";
    case KeyEvent.KEYCODE_MENU:
        return "<Menu>";
    case KeyEvent.KEYCODE_MINUS:
        return "<->";
    case KeyEvent.KEYCODE_NOTIFICATION:
        return "<??? 3>";
    case KeyEvent.KEYCODE_NUM:
        return "<Num>";
    case KeyEvent.KEYCODE_PERIOD:
        return "<??? 4>";
    case KeyEvent.KEYCODE_PLUS:
        return "<+>";
    case KeyEvent.KEYCODE_POUND:
        return "<??? 5>";
    case KeyEvent.KEYCODE_POWER:
        return "<Power>";
    case KeyEvent.KEYCODE_RIGHT_BRACKET:
        return "<)>";
    case KeyEvent.KEYCODE_SEMICOLON:
        return "<;>";
    case KeyEvent.KEYCODE_SLASH:
        return "</>";
    case KeyEvent.KEYCODE_SOFT_LEFT:
        return "<??? 6>";
    case KeyEvent.KEYCODE_SOFT_RIGHT:
        return "<??? 7>";
    case KeyEvent.KEYCODE_SPACE:
        return "<Space>";
    case KeyEvent.KEYCODE_STAR:
        return "<*>";
    case KeyEvent.KEYCODE_SYM:
        return "<Sym>";
    case KeyEvent.KEYCODE_TAB:
        return "<Tab>";
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        return "<VolumeDown>";
    case KeyEvent.KEYCODE_VOLUME_UP:
        return "<VolumeUp>";
    case KeyEvent.KEYCODE_UNKNOWN:
    default:/*  ww  w . j a va 2s  .c om*/
        return "<Unknown>";
    }
}

From source file:com.luyaozhou.recognizethisforglass.ViewFinder.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_CAMERA: { // camera button (hardware)
        if (keyEnable) {

            camera.stopPreview(); // stop the preview
            camera.release(); // release the camera
            previewOn = false;/* ww w  .  ja  va 2 s  .c o  m*/

            keyEnable = false;
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image
                    if (intent.resolveActivity(getPackageManager()) != null) {
                        startActivityForResult(intent, PHOTO_REQUEST_CODE);
                    }
                }
            });

        }
        // Return false to allow the camera button to do its default action
        return false;

    }
    case KeyEvent.KEYCODE_DPAD_CENTER: // touchpad tap
    case KeyEvent.KEYCODE_ENTER: {

        if (keyEnable) {

            camera.stopPreview();
            camera.release();

            previewOn = false; // Don't release the camera in surfaceDestroyed()

            keyEnable = false;
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image
                    if (intent.resolveActivity(getPackageManager()) != null) {
                        startActivityForResult(intent, PHOTO_REQUEST_CODE);
                    }
                }
            });

        }
        return false;
    }
    default: {
        return super.onKeyDown(keyCode, event);
    }
    }
}

From source file:com.jwetherell.QRComm575.DecoderActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) {
        // Handle these events so they don't launch the Camera app
        return true;
    }/*w w w.  ja  v a 2 s .  com*/
    return super.onKeyDown(keyCode, event);
}

From source file:com.jtxdriggers.android.ventriloid.Connected.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.connected);/* ww  w . j av  a  2s .c  om*/

    getSupportActionBar().setSubtitle("Checking Latency...");

    sm = new VentriloidSlidingMenu(this);
    sm.attachToActivity(this, VentriloidSlidingMenu.SLIDING_CONTENT);
    sm.makeViewPersistent(this, R.id.bottomBar);
    sm.getListView().setOnChildClickListener(menuClickListener);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    bottomBar = (RelativeLayout) findViewById(R.id.bottomBar);

    if (!prefs.getBoolean("voice_activation", false)) {
        pttToggle = prefs.getBoolean("toggle_mode", false);
        pttEnabled = prefs.getBoolean("custom_ptt", false);
        pttKey = pttEnabled ? prefs.getInt("ptt_key", KeyEvent.KEYCODE_CAMERA) : -1;

        pttSizeUp = (Button) findViewById(R.id.pttSizeUp);
        pttSizeUp.setOnClickListener(sizeChangeListener);
        pttSizeDown = (Button) findViewById(R.id.pttSizeDown);
        pttSizeDown.setOnClickListener(sizeChangeListener);
        ptt = (Button) findViewById(R.id.ptt);
        ptt.setOnTouchListener(new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    if (pttToggle) {
                        toggleOn = !toggleOn;
                        s.setPTTOn(toggleOn);
                        bottomBar.setBackgroundResource(toggleOn ? R.drawable.blue_gradient_bg
                                : R.drawable.abs__ab_bottom_solid_light_holo);
                        return true;
                    } else {
                        s.setPTTOn(true);
                        bottomBar.setBackgroundResource(R.drawable.blue_gradient_bg);
                        return true;
                    }
                } else if (!pttToggle && event.getAction() == MotionEvent.ACTION_UP) {
                    s.setPTTOn(false);
                    bottomBar.setBackgroundResource(R.drawable.abs__ab_bottom_solid_light_holo);
                    return true;
                }
                return false;
            }
        });

        setPTTSize(prefs.getInt("ptt_size", SMALL));
    } else
        bottomBar.setVisibility(LinearLayout.GONE);

    chatId = getIntent().getShortExtra("id", (short) -1);

    if (getDefaultSharedPreferences().getBoolean("v3FirstConnect", true)) {
        AlertDialog.Builder firstRun = new AlertDialog.Builder(this);
        firstRun.setMessage(
                "To display the menu, press the Menu button at the top-right or your screen, or swipe your finger from left to right.");
        firstRun.setNegativeButton("Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        firstRun.show();
        getDefaultSharedPreferences().edit().putBoolean("v3FirstConnect", false).commit();
    }
}

From source file:com.marcopolci.paperwalletvalidator.MainActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // don't launch camera app
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
        ScanFragment fragment = (ScanFragment) getFragmentManager().findFragmentById(R.id.fragmentScan);
        fragment.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP);
        return true;
    }/*from   w ww.ja  v a 2 s  .c  o m*/

    return super.onKeyDown(keyCode, event);
}

From source file:com.coinomi.wallet.ui.ScanActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // don't launch camera app
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
        cameraHandler.post(new Runnable() {
            @Override/* w w w  . java  2s  .com*/
            public void run() {
                cameraManager.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP);
            }
        });
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:gov.nasa.arc.geocam.geocam.CameraPreviewActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_CAMERA:
    case KeyEvent.KEYCODE_DPAD_CENTER:
        // Return here after catching camera keycode so we don't launch the built-in camera app
        return true;
    }/*from  ww w .j  a  v a2  s  .  c o  m*/
    return super.onKeyDown(keyCode, event);
}

From source file:co.jlabs.cersei_retailer.zxingfragmentlib.BarCodeScannerFragment.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    // Use volume up/down to turn on light
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        //                cameraManager.setTorch(false);
        setTorchOff();//from w  w  w  . j a  v a  2  s .  co m
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        setTorchOn();
        return true;
    }
    return false; //super.onKeyDown(keyCode, event);
}

From source file:com.google.zxing.demo.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        finish();/* w ww. ja va2  s . com*/
        return true;
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        setResult(RESULT_CANCELED);//w  w w .  j a va2 s .  c  o m
        finish();
        break;
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    // Use volume up/down to turn on light
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        cameraManager.setTorch(false);
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        cameraManager.setTorch(true);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}