/*
* 图片查看和录音播放
* @param int 0图片,1录音
* @param String 本地路径
* */
private void showImgAudio(int type,String fileUrl ){
String authority = BaseFileUtil.FileProviderAuthorities;// "你的包名.fileprovider"
File file = new File(fileUrl);
Uri uri;
Intent intent = new Intent(Intent.ACTION_VIEW);
if (Build.VERSION.SDK_INT >= 24) {
uri = FileProvider.getUriForFile(mContext, authority, file);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);//注意加上这句话
} else {
uri = Uri.fromFile(new File(fileUrl));
}
intent.setDataAndType(uri, type==0?"image/*":"audio/MP3");
mContext.startActivity(intent);
}
网友评论