本文整理汇总了Java中com.android.camera.util.CameraUtil.openCamera方法的典型用法代码示例。如果您正苦于以下问题:Java CameraUtil.openCamera方法的具体用法?Java CameraUtil.openCamera怎么用?Java CameraUtil.openCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.camera.util.CameraUtil
的用法示例。
在下文中一共展示了CameraUtil.openCamera方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareCamera
import com.android.camera.util.CameraUtil; //导入方法依赖的package包/类
/**
* Opens the camera device.
*
* @return Whether the camera was opened successfully.
*/
private boolean prepareCamera() {
// We need to check whether the activity is paused before long
// operations to ensure that onPause() can be done ASAP.
mCameraDevice = CameraUtil.openCamera(
mActivity, mCameraId, mHandler,
mActivity.getCameraOpenErrorCallback());
if (mCameraDevice == null) {
Log.e(TAG, "Failed to open camera:" + mCameraId);
return false;
}
mParameters = mCameraDevice.getParameters();
initializeCapabilities();
if (mFocusManager == null) initializeFocusManager();
setCameraParameters(UPDATE_PARAM_ALL);
mHandler.sendEmptyMessage(CAMERA_OPEN_DONE);
mCameraPreviewParamsReady = true;
startPreview();
mOnResumeTime = SystemClock.uptimeMillis();
checkDisplayRotation();
return true;
}
示例2: openCamera
import com.android.camera.util.CameraUtil; //导入方法依赖的package包/类
/**
* Opens the camera device. The back camera has priority over the front
* one.
*
* @return Whether the camera was opened successfully.
*/
private boolean openCamera() {
int cameraId = CameraHolder.instance().getBackCameraId();
// If there is no back camera, use the first camera. Camera id starts
// from 0. Currently if a camera is not back facing, it is front facing.
// This is also forward compatible if we have a new facing other than
// back or front in the future.
if (cameraId == -1) cameraId = 0;
mCameraDevice = CameraUtil.openCamera(mActivity, cameraId,
mMainHandler, mActivity.getCameraOpenErrorCallback());
if (mCameraDevice == null) {
return false;
}
mCameraOrientation = CameraUtil.getCameraOrientation(cameraId);
if (cameraId == CameraHolder.instance().getFrontCameraId()) mUsingFrontCamera = true;
return true;
}
示例3: switchCamera
import com.android.camera.util.CameraUtil; //导入方法依赖的package包/类
private void switchCamera() {
if (mPaused) return;
Log.v(TAG, "Start to switch camera. id=" + mPendingSwitchCameraId);
mCameraId = mPendingSwitchCameraId;
mPendingSwitchCameraId = -1;
setCameraId(mCameraId);
// from onPause
closeCamera();
mUI.collapseCameraControls();
mUI.clearFaces();
if (mFocusManager != null) mFocusManager.removeMessages();
// Restart the camera and initialize the UI. From onCreate.
mPreferences.setLocalId(mActivity, mCameraId);
CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
mCameraDevice = CameraUtil.openCamera(
mActivity, mCameraId, mHandler,
mActivity.getCameraOpenErrorCallback());
if (mCameraDevice == null) {
Log.e(TAG, "Failed to open camera:" + mCameraId + ", aborting.");
return;
}
mParameters = mCameraDevice.getParameters();
initializeCapabilities();
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
mMirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
mFocusManager.setMirror(mMirror);
mFocusManager.setParameters(mInitialParams);
setupPreview();
// reset zoom value index
mZoomValue = 0;
openCameraCommon();
// Start switch camera animation. Post a message because
// onFrameAvailable from the old camera may already exist.
mHandler.sendEmptyMessage(SWITCH_CAMERA_START_ANIMATION);
}
示例4: openCamera
import com.android.camera.util.CameraUtil; //导入方法依赖的package包/类
private void openCamera() {
if (mCameraDevice == null) {
mCameraDevice = CameraUtil.openCamera(
mActivity, mCameraId, mHandler,
mActivity.getCameraOpenErrorCallback());
}
if (mCameraDevice == null) {
// Error.
return;
}
mParameters = mCameraDevice.getParameters();
}