如何在安卓手机中自动拍照? [英] How to capture photo automatically in android phone?
本文介绍了如何在安卓手机中自动拍照?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了一个安卓应用程序.因为我使用了前置摄像头功能.它工作正常,但我需要自动捕获.即没有单击快门按钮的声音,我想捕获照片代码..
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..
我的相机活动代码是
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;
}
提前谢谢..
推荐答案
按照 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());
这篇关于如何在安卓手机中自动拍照?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文