Bitmap으로 불러오면 사진이 오지게 깨진다.
Uri image;
String mCameraFileName;
private void a() {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
Intent intent = new Intent();
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
Date date = new Date();
DateFormat df = new SimpleDateFormat("-mm-ss");
String newPicFile = df.format(date) + ".jpg";
String outPath = "/sdcard/" + newPicFile;
File outFile = new File(outPath);
mCameraFileName = outFile.toString();
Uri outuri = Uri.fromFile(outFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outuri);
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
a메소드 호출 후
if (data != null) {
image = data.getData();
}
if (image == null && mCameraFileName != null) {
image = Uri.fromFile(new File(mCameraFileName));
}
File file = new File(mCameraFileName);
if (!file.exists()) {
file.mkdir();
}
or cache하기
ref _ https://sites.google.com/site/justenjoysomething/android/file-cache
uri를 가져옴
+ crop library
https://github.com/ArthurHub/Android-Image-Cropper
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>