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);
startActivity(intent);
//根据文件后缀名匹配MIMEType public static String getMIMEType(File file) { String type = "*/*"; String name = file.getName(); int index = name.lastIndexOf('.'); if (index < 0) { return type; } String end = name.substring(index, name.length()).toLowerCase(); if (TextUtils.isEmpty(end)) return type; for (int i = 0; i < MIME_MapTable.length; i++) { if (end.equals(MIME_MapTable[i][0])) type = MIME_MapTable[i][1]; } return type; } private static final String[][] MIME_MapTable = {