public void stopCamera() { if (mCamera != null) { mPreviewFrame.removeView(mPreview); } Log.d(TAG, "stopping camera"); mCameraHandler.sendEmptyMessage(STOP_PREVIEW); mCameraHandler.sendEmptyMessage(RELEASE); mHandler.removeCallbacks(cameraFocusRunner); mPreviewing = false; }
public void setFlashOn(boolean on) { // You have camera in your device if (hasCameraFlash()) { if (on) { mFlashOn = true; mCameraHandler.sendEmptyMessage(FLASH_ON); } else { mFlashOn = false; mCameraHandler.sendEmptyMessage(FLASH_OFF); } } }
@Override public CameraManager.CameraProxy cameraOpen( Handler handler, int cameraId, CameraOpenErrorCallback callback) { mCameraHandler .obtainMessage( OPEN_CAMERA, cameraId, 0, CameraOpenErrorCallbackForward.getNewInstance(handler, callback)) .sendToTarget(); mCameraHandler.waitDone(); if (mCamera != null) { return new AndroidCameraProxyImpl(); } else { return null; } }
private void finishOpenCamera() { mPreview = new CameraSurfacePreview(mFragment.getActivity(), mCamera); mCameraHandler.sendEmptyMessage(SETUP); mPreviewing = true; mHandler.post( new Runnable() { public void run() { mPreviewFrame.addView(mPreview); } }); }
private void startupTheCamera() { if (mFragment.getActivity() == null) { return; } final int cameraIndex = pickCamera(); if (cameraIndex < 0) { return; } mCameraHandler.post( new Runnable() { public void run() { try { Log.d(TAG, "Opening Camera"); mCamera = Camera.open(cameraIndex); finishOpenCamera(); } catch (Exception e) { Log.e(TAG, "Camera Does Not exist", e); mHandler.postDelayed(mCameraStartRunner, 500); } } }); }
@Override public void run() { mCameraHandler.sendEmptyMessage(AUTO_FOCUS); mHandler.postDelayed(cameraFocusRunner, FOCUS_MILLIS); }
public void stopScanning() { mCameraHandler.sendEmptyMessage(PREVIEW_OFF); }
public void startScanning() { mCameraHandler.sendEmptyMessage(PREVIEW_ON); }
@Override protected void onDestroy() { Log.d(TAG, "onDestroy"); super.onDestroy(); mCameraHandler.invalidateHandler(); // paranoia }