在使用拍照並裁剪的時候,用以下代碼:java
//拍照並裁剪 takePhoto.onPickFromCaptureWithCrop(imageUri, getCropOptions());
發現拍照時沒法進入裁剪頁面,LOG提示app
takeCancel操做被取消code
查驗代碼,原來代碼以下:在TUriParse.javaorm
public static Uri getTempUri(Context context) { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); File file = new File(Environment.getExternalStorageDirectory(), "/images/" + timeStamp + ".jpg"); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } return getUriForFile(context, file); }
修改成以下代碼,就能夠拍照裁剪啦:get
public static Uri getTempUri(Context context) { ContextWrapper cw = new ContextWrapper(context); File directory = cw.getExternalFilesDir(Environment.DIRECTORY_PICTURES); File file = new File(directory, "/images/" +System.currentTimeMillis() + ".jpg"); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); //File file = new File(Environment.getExternalStorageDirectory(), "/images/" + timeStamp + ".jpg"); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } return getUriForFile(context, file); }