我想从前置摄像头拍摄照片,没有任何按钮拍照并自动保存
我的代码:
final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/picFolder/";
File newdir = new File(dir);
newdir.mkdirs();
String file2 = dir+"test.jpg";
File newfile = new File(file2);
try {
newfile.createNewFile();
}
catch (IOException e)
{
}
File image = new File(dir, "image.jpg");
Uri uriSavedImage = Uri.fromFile(image);
Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(imageIntent, 0);