1.打开图片
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://"+"/sdcard/test.jpg"),"image/*");
startActivity(intent);
2.打开PPT,Word,excel文件
Intent intent = new Intent(Intent.ACTION_VIEW);
//intent.setDataAndType(Uri.parse("file://"+file_path),"application/vnd.ms-excel");
intent.setDataAndType(Uri.parse("file://"+file_path),"application/msword");
startActivity(intent);
3.打开PDF文件
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);