在调用系统相机拍照的时候突在某些机型上发现拍出来的照片有可能已经不是原来的角度 不是旋转了90度就是旋转了180度,为了适配这个问题下面是一波套路、、、
调用系统相机:
/**
* 打开系统相机记录成长图片
*/
private void showCamera(int cameraType) {
if (!Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
Toast.makeText(getActivity(), "未检测到SDCard,拍照功能暂时停用",
Toast.LENGTH_LONG).show();
return;
}
Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
long time = currentTimeMillis();
String imgName = new SimpleDateFormat("yyyyMMdd_HHmmss").format(time);
String path = Environment.getExternalStorageDirectory()
+ File.separator + "DCIM" + File.separator + "Camera"
+ File.separator;
File file = new File(path);
if (!file.exists()) {
file.mkdir();
}
cameraFilePath = path + imgName + ".jpg"; //拍照保存文件路径+文件名称+文件格式
File out = new File(cameraFilePath);
if (!out.exists()) {
try {
out.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Uri uri = Uri.fromFile(out);
imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
MediaScannerConnection.scanFile(getActivity(),
new String[]{cameraFilePath}, null, null);
startActivityForResult(image