如何在android手机自动拍摄照片么

如何在android手机自动拍摄照片么

本文介绍了如何在android手机自动拍摄照片么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Android应用程序。在这我已经使用前置摄像头功能。它工作正常,但我需要自动捕获。即不按快门按钮的声音,我想拍摄照片​​code ..

I have developed an android application. In that i have used front facing camera functionality. Its working fine but I need to auto capture. i.e. without click shutter button sound, I want to capture photocode..

我的相机活性 code是

 private Camera openFrontFacingCameraGingerbread() {
    int cameraCount = 0;
    Camera cam = null;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    cameraCount = Camera.getNumberOfCameras();
    for ( int camIdx = 0; camIdx < cameraCount; camIdx++ ) {
        Camera.getCameraInfo( camIdx, cameraInfo );
        if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT  ) {
            try {
                cam = Camera.open( camIdx );
            } catch (RuntimeException e) {
                Log.i("Camera failed to open: ",e.getLocalizedMessage());
            }
        }
    }
    return cam;
}

在此先感谢。

Thanks in advance..

推荐答案

请在Android开发者所列的步骤的。有没有需要有一个'快门按钮。你可以创建一个虚拟SurfaceHolder,如果你不希望显示图像在屏幕上,如:

Follow the steps outlined in the Android Developer reference pages. There's no requirement to have a 'shutter button'. You can create a dummy SurfaceHolder if you don't want to show the image on the screen, e.g.

SurfaceView surface = new SurfaceView(context);
cam.setPreviewDisplay(surface.getHolder());

这篇关于如何在android手机自动拍摄照片么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:58