您的位置:首页 > 其它

由文件的路径通过其他应用打开图片,PPT,Word,excel,PDF

2016-09-09 19:11 579 查看
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);



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐