嗨,我正在寻找一种直接从相机设备保存照片而不要求用户保存或不保存的方法。我没有实现相机类或覆盖它。我只是使用上面的这段代码。你有什么想法吗?
TextReader tr = new TextReader(TextReader.DIRECTORY_EMPRESAS);
String path = TextReader.PARENT_PATH + "/" + TextReader.DIRECTORY_IMAGES;
String dataAtual = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
if(tr.verificaDiretorios(path)){
String pictureName = dataAtual + DADOS.get(0) + ".jpg";
File pathEmpresa = new File(path + "/" + TextReader.FILE_NAME);
File imageFile;
if(pathEmpresa.exists()){
imageFile = new File(pathEmpresa, pictureName);
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
//startActivity(i);
startActivityForResult(i, 2);
}else{
if(pathEmpresa.mkdir()){
imageFile = new File(pathEmpresa, pictureName);
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
//startActivity(i);
startActivityForResult(i, 2);
}else{
throw new IllegalStateException("Não foi possivel criar o diretorio: " + pathEmpresa);
}
}