调用系统打开图片
Intent intent = new Intent();
File file = new File(fileName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Intent.ACTION_VIEW);
String type = ImageUtils.getMIMEType(file);
//设置intent的data和Type属性。
intent.setDataAndType(Uri.fromFile(file), type);
报异常:FileUriExposedException
解决办法:
在自定义的Application的onCreate方法中添加如下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
}
详情参考:http://blog.csdn.net/xiaoyu940601/article/details/54406725