public class CallOtherOpenFile { public void openFile(Context context,String path) { File file = new File(path); if (!file.exists()) { Toast.makeText(context, "请先下载学习资料!", Toast.LENGTH_SHORT).show(); return; } try { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //设置intent的Action属性 intent.setAction(Intent.ACTION_VIEW); //获取文件file的MIME类型 String type = getMIMEType(file); //设置intent的data和Type属性。 intent.setDataAndType(/*uri*/Uri.fromFile(file), type); //跳转 context.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(context, "sorry附件不能打开,请下载相关软件!", Toast.LENGTH_SHORT).show(); } } private String getMIMEType(File file) {