Android 7.0 调取相机崩溃 android.os.FileUriExposedException
来源:互联网 发布:ubuntu smbpassword 编辑:程序博客网 时间:2024/06/04 01:26
/**
* 选择相机
*/
private void showCameraAction() {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(getPackageManager()) != null) {
// 设置系统相机拍照后的输出路径
mTmpFile = FileUtil.createTmpFile(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
doTakePhotoIn7(mTmpFile.getAbsolutePath());
} else {
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(mTmpFile));
startActivityForResult(cameraIntent,
CameraSdkParameterInfo.TAKE_PICTURE_FROM_CAMERA);
}
} else { Toast.makeText(this, R.string.camerasdk_msg_no_camera, Toast.LENGTH_SHORT).show(); }}//在Android7.0以上拍照private void doTakePhotoIn7(String path) { Uri mCameraTempUri; try { ContentValues values = new ContentValues(1); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg"); values.put(MediaStore.Images.Media.DATA, path); mCameraTempUri = getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); takePhoto(CameraSdkParameterInfo.TAKE_PICTURE_FROM_CAMERA, mCameraTempUri); } catch (Exception e) { e.printStackTrace(); }}public void takePhoto(int requestCode, Uri uri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); if (uri != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); } startActivityForResult(intent, requestCode);}@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // 相机拍照完成后,返回图片路径 if (requestCode == CameraSdkParameterInfo.TAKE_PICTURE_FROM_CAMERA) { if (resultCode == Activity.RESULT_OK) { mTmpFile 就是你的拍好照之后的文件 ....... //注意 提前命名的file 此时在这里 data为空 不要通过data在获取你的file路径 } }}
- Android 7.0 调取系统相机崩溃解决android.os.FileUriExposedException
- Android 7.0 调取相机崩溃 android.os.FileUriExposedException
- 【适配整理】Android 7.0 调取系统相机崩溃解决android.os.FileUriExposedException
- Android 7.0 系统相机崩溃解决android.os.FileUriExposedException
- 解决Android7.0相机 android.os.FileUriExposedException
- android 7.0 + 相机拍照 FileUriExposedException
- android 7.0 + 相机拍照 FileUriExposedException
- Android 7.0 android.os.FileUriExposedException
- 解决android 7.0系统,调用相机报:android.os.FileUriExposedException错
- Android 7.0调用系统相机(文件访问crash android.os.FileUriExposedException)
- android.os.FileUriExposedException 解决方法
- android.os.FileUriExposedException
- android.os.FileUriExposedException
- android 7.0的android.os.FileUriExposedException: 问题解决
- Android 7.0 报android.os.FileUriExposedException异常
- Android 7.0 调用系统相机崩溃解决 android.os.FileUriException
- Android 7.0调用系统相机报错Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/rpms/14
- Android7.0 android.os.FileUriExposedException
- vs 2017问题
- Framework学习(九)Broadcast的注册、发送和接收过程
- Android 中图片实现圆形显示
- LeetCode 672. Bulb Switcher II
- M
- Android 7.0 调取相机崩溃 android.os.FileUriExposedException
- tomcat8配置apr模式
- 验证Java传值是传应用还是传副本
- js手动聚焦输入框或者文本域_focus
- 请描述一下cookie、sessionStorage、localStorage的区别。
- Linux单元小结(6)
- ABAP程序优化
- 【20171010】面向对象分析与设计方法
- build模式的第二篇