/**
* 获取图片原图
*/
protected void getImageFromCamera() {
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
Intent getImageByCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
StringBuilder pathBuilder = new StringBuilder();
String out_file_path = Environment.getExternalStorageDirectory().getPath();
//路径
pathBuilder.append(out_file_path).append(File.separator).append("Test").append(File.separator);
//文件名
pathBuilder.append("temps.jpg");
uploadPhotPath = pathBuilder.toString();
File filePath = new File(uploadPhotPath);
if (!filePath.getParentFile().exists()) {
filePath.getParentFile().mkdirs();
}
getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filePath));
getImageByCamera.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(getImageByCamera, CAPTURE_CODE);
} else {
Toast.makeText(getApplicationContext(), "请确认已经插入SD卡", Toast.LENGTH_LONG).show();
}
}
转载于:https://my.oschina.net/u/2293736/blog/649387