当前位置: 首页>>代码示例>>Java>>正文


Java ViewfinderView.setCameraManager方法代码示例

本文整理汇总了Java中cn.hugo.android.scanner.view.ViewfinderView.setCameraManager方法的典型用法代码示例。如果您正苦于以下问题:Java ViewfinderView.setCameraManager方法的具体用法?Java ViewfinderView.setCameraManager怎么用?Java ViewfinderView.setCameraManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.hugo.android.scanner.view.ViewfinderView的用法示例。


在下文中一共展示了ViewfinderView.setCameraManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResume

import cn.hugo.android.scanner.view.ViewfinderView; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    // CameraManager must be initialized here, not in onCreate(). This is
    // necessary because we don't
    // want to open the camera driver and measure the screen size if we're
    // going to show the help on
    // first launch. That led to bugs where the scanning rectangle was the
    // wrong size and partially
    // off screen.

    // 相机初始化的动作需要开启相机并测量屏幕大小,这些操作
    // 不建议放到onCreate中,因为如果在onCreate中加上首次启动展示帮助信息的代码的 话,
    // 会导致扫描窗口的尺寸计算有误的bug
    cameraManager = new CameraManager(getApplication());

    viewfinderView = (ViewfinderView) findViewById(R.id.capture_viewfinder_view);
    viewfinderView.setCameraManager(cameraManager);

    handler = null;
    lastResult = null;

    // 摄像头预览功能必须借助SurfaceView,因此也需要在一开始对其进行初始化
    // 如果需要了解SurfaceView的原理
    // 参考:http://blog.csdn.net/luoshengyang/article/details/8661317
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.capture_preview_view); // 预览
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        // The activity was paused but not stopped, so the surface still
        // exists. Therefore
        // surfaceCreated() won't be called, so init the camera here.
        initCamera(surfaceHolder);
    } else {

        // 防止sdk8的设备初始化预览异常
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        // Install the callback and wait for surfaceCreated() to init the
        // camera.
        surfaceHolder.addCallback(this);
    }

    // 加载声音配置,其实在BeemManager的构造器中也会调用该方法,即在onCreate的时候会调用一次
    beepManager.updatePrefs();
    // 启动闪光灯调节器
    ambientLightManager.start(cameraManager);
    // 恢复活动监控器
    inactivityTimer.onResume();
    source = IntentSource.NONE;
    decodeFormats = null;
    characterSet = null;

}
 
开发者ID:oneapp1e,项目名称:BarcodeScanner,代码行数:54,代码来源:CaptureActivity.java

示例2: onResume

import cn.hugo.android.scanner.view.ViewfinderView; //导入方法依赖的package包/类
@Override
protected void onResume() {
	super.onResume();

	// CameraManager must be initialized here, not in onCreate(). This is
	// necessary because we don't
	// want to open the camera driver and measure the screen size if we're
	// going to show the help on
	// first launch. That led to bugs where the scanning rectangle was the
	// wrong size and partially
	// off screen.

	// 相机初始化的动作需要开启相机并测量屏幕大小,这些操作
	// 不建议放到onCreate中,因为如果在onCreate中加上首次启动展示帮助信息的代码的 话,
	// 会导致扫描窗口的尺寸计算有误的bug
	cameraManager = new CameraManager(getApplication());

	viewfinderView = (ViewfinderView) findViewById(R.id.capture_viewfinder_view);
	viewfinderView.setCameraManager(cameraManager);

	handler = null;
	lastResult = null;

	// 摄像头预览功能必须借助SurfaceView,因此也需要在一开始对其进行初始化
	// 如果需要了解SurfaceView的原理
	// 参考:http://blog.csdn.net/luoshengyang/article/details/8661317
	SurfaceView surfaceView = (SurfaceView) findViewById(R.id.capture_preview_view); // 预览
	SurfaceHolder surfaceHolder = surfaceView.getHolder();
	if (hasSurface) {
		// The activity was paused but not stopped, so the surface still
		// exists. Therefore
		// surfaceCreated() won't be called, so init the camera here.
		initCamera(surfaceHolder);

	}
	else {
		// 防止sdk8的设备初始化预览异常
		surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

		// Install the callback and wait for surfaceCreated() to init the
		// camera.
		surfaceHolder.addCallback(this);
	}

	// 加载声音配置,其实在BeemManager的构造器中也会调用该方法,即在onCreate的时候会调用一次
	beepManager.updatePrefs();

	// 启动闪光灯调节器
	ambientLightManager.start(cameraManager);

	// 恢复活动监控器
	inactivityTimer.onResume();

	source = IntentSource.NONE;
	decodeFormats = null;
	characterSet = null;
}
 
开发者ID:yuxiaohui78,项目名称:android_develop,代码行数:58,代码来源:CaptureActivity.java


注:本文中的cn.hugo.android.scanner.view.ViewfinderView.setCameraManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。