有意图地捕捉图像,无需再次单击相机按钮
我想通过 Intent
IntentcameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE)
捕获图像,但问题是使用此代码相机启动,用户必须单击相机按钮来捕获图像,但是什么我想要的是相机应该启动并拍照,而无需与用户进行任何进一步的交互
我想使用 INTENT 来做到这一点
I want to capture images through Intent
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE)
but the problem is that with this code the camera is started and the user has to click on the camera button to capture the image , but what i want is that the camera sholud start and take picture without any furthur interaction with the user
I want to do this using INTENT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我就是这样做的:
声明 Camera 和 SurfaceHolder 的实例。
创建一个CallBackPicture对象,并实现PictureTaken上的方法(当你想拍照时启动的方法)
通过修改这个,你应该能够做你想做的事情。
不要忘记也修改 Manifest.XML,但我认为您已经完成了!
编辑:有时 stoppreview() 和 release() 会出现一些问题。
所以,我所做的事情是:
That is the way I did it :
Declare an instance of Camera, and SurfaceHolder.
Create an Object CallBackPicture, and implements the method on PictureTaken (method launched when you want to take a picture)
By modifying this, you should be able to do what you want..
Don't forget to modify the Manifest.XML too, but I think you've already done it!
EDIT : sometimes there is some problem with stoppreview() and release()..
So, the thing i've done is :
这是不可能的。只有两个选项:
通过 Intent 调用相机应用程序。然后,用户以正常方式使用相机应用程序 - 即准备好后按下按钮。
使用
Camera
类 - 这个与通过 Intent 运行相机应用程序相比,工作量要大得多。但它给了你完全的控制权。This can't be done. There are only two options:
Invoking Camera app via Intent. The user then uses Camera app in normal way - i.e. presses the button when ready.
Use
Camera
class - this is much more work compared to running Camera app via Intent. But it gives you full control.当您调用相机意图时,您基本上“运行”相机应用程序(或在此意图上注册的其他应用程序),因此基本上,您无法控制它的工作方式。
您可以使用相机 API...请查看此处
When you call the camera intent you basically "run" the camera app (or other app that registered on this intent), so basically, you can't control of how it works.
You can use the Camera API...take a look here