Using the camera
How-To Program The Google Android Camera To Take Pictures
Take Picture from Camera Emulator
camera
首先编辑你的AndroIDManifest.xml,添加摄像机权限:
<uses-permission androID:name=”androID.permission.CAMERA”/>
相机服务必须打开和关闭:
Camera camera = Camera.open(); //Do things with the cameracamera.release();
您可以设置相机设置,例如:
Camera.Parameters parameters = camera.getParameters();parameters.setPictureFormat(PixelFormat.JPEG); camera.setParameters(parameters);
拍照:
private voID takePicture() { camera.takePicture(shutterCallback,rawCallback,jpegCallback); }ShutterCallback shutterCallback = new ShutterCallback() { public voID onShutter() { // Todo Do something when the shutter closes. }};PictureCallback rawCallback = new PictureCallback() { public voID onPictureTaken(byte[] _data,Camera _camera) { // Todo Do something with the image RAW data. }};PictureCallback jpegCallback = new PictureCallback() { public voID onPictureTaken(byte[] _data,Camera _camera) { // Todo Do something with the image JPEG data. }};
不要忘了将相机布局添加到主布局xml中.
总结以上是内存溢出为你收集整理的java – 如何在Android手机上访问相机?全部内容,希望文章能够帮你解决java – 如何在Android手机上访问相机?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)