我正在使用Android 5.0实现应用程序,该应用程序允许自动捕获图像并将其保存到手机中。目前,我正在使用波纹管代码,但它需要按下手机的Capture UI中的捕捉按钮。是否可以在不按下捕捉按钮的情况下捕捉并保存图像?例如,我只需调用功能myCaptureandSave()
,然后手机将显示Capture UI并中间捕捉图像并保存,我不需要再执行更多操作。如何自动捕捉并保存图像,而无需在Android中按捕捉按钮?
public void myCaptureandSave() {
String image_path = Environment.getExternalStorageDirectory() +"/"+System.currentTimeMillis()+".jpg";
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
//File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File output = new File(image_path);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(output));
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
你不能这样做的意图。意图打开其他应用程序。你必须制作自己的相机应用程序。 Folow [这](https://developer.android.com/guide/topics/media/camera.html#custom-camera)的说明 –