【1】问题原因
【2】解决方案
参考链接:
http://www.jianshu.com/p/68a4e8132fcd
http://blog.csdn.net/qq_35001400/article/details/72866770
http://www.cnblogs.com/yongdaimi/p/6067319.html
http://www.jianshu.com/p/9f1dbf6a3114
https://bugly.qq.com/v2/crash-reporting/crashes/6e91d75409/82?pid=1
【2.1】
【2.2】
【2.3】
photopicker图片源代码更改
【1】ImageCaptureManager.java 62 72
/*
public Intent dispatchTakePictureIntent() throws IOException {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(mContext.getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = createImageFile();
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
}
}
return takePictureIntent;
}
public void galleryAddPic() {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(mCurrentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
mContext.sendBroadcast(mediaScanIntent);
}
*/
/* longhui20171107 兼容Android7运行Uri.fromFile修改*/
public Intent dispatchTakePictureIntent() throws IOException {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri uri;
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(mContext.getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = createImageFile();
// Continue only if the File was successfully created
if (photoFile != null) {
/* longhui20171107 兼容Android7运行Uri.fromFile修改,SDK大于24就出错*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){//24
uri = FileProvider.getUriForFile(mContext,"com.ueh.hcdriver.fileprovider",photoFile);
}else {
uri = Uri.fromFile(photoFile);
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
}
}
return takePictureIntent;
}
public void galleryAddPic() {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(mCurrentPhotoPath);
Uri contentUri;
/* longhui20171107 兼容Android7运行Uri.fromFile修改,SDK大于24就出错*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){//24
contentUri = FileProvider.getUriForFile(mContext,"com.ueh.hcdriver.fileprovider",f);
}else {
contentUri = Uri.fromFile(f);
}
mediaScanIntent.setData(contentUri);
mContext.sendBroadcast(mediaScanIntent);
}
【2】photopagerAdapter.java 56行
final String path = paths.get(position);
final Uri uri;
if (path.startsWith("http")) {
uri = Uri.parse(path);
} else {
/* longhui20171107 兼容Android7运行Uri.fromFile修改,SDK大于24就出错*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){//24
uri = FileProvider.getUriForFile(mContext,"com.ueh.hcdriver.fileprovider",new File(path));
}else {
uri = Uri.fromFile(new File(path));
}
}