在使用拍照並裁剪的時候,用如下程式碼:
//拍照並裁剪takePhoto。onPickFromCaptureWithCrop(imageUri, getCropOptions());
發現拍照時無法進入裁剪頁面,LOG提示
takeCancel操作被取消
查驗程式碼,原來程式碼如下:在TUriParse。java
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);}
修改為如下程式碼,就可以拍照裁剪啦:
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);}