Intent打开各种类型的文件
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Intent打开各种类型的文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                
                            
                            
                            需要用到Intent.setDataAndType(path,type)函數 模板: //android獲取一個用于打開PPT文件的intent 
? public static Intent getPptFileIntent( String param )
? {
??? Intent intent = new Intent("android.intent.action.VIEW");
??? intent.addCategory("android.intent.category.DEFAULT");
??? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
??? Uri uri = Uri.fromFile(new File(param ));
??? intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
??? return intent;
? }
打開不同類型的文件只需要修改參數type即可: 打開APK——application/vnd.android.package-archive 打開PPT——application/vnd.ms-powerpoint 打開Excel——application/vnd.ms-excel 打開Word——application/msword 打開CHM——application/x-chm 打開文本txt——text/plain 打開PDF——application/pdf 打開VCF——text/x-vcard 打開SWF——flash/*
 
 
                        
                        
                        ? public static Intent getPptFileIntent( String param )
? {
??? Intent intent = new Intent("android.intent.action.VIEW");
??? intent.addCategory("android.intent.category.DEFAULT");
??? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
??? Uri uri = Uri.fromFile(new File(param ));
??? intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
??? return intent;
? }
打開不同類型的文件只需要修改參數type即可: 打開APK——application/vnd.android.package-archive 打開PPT——application/vnd.ms-powerpoint 打開Excel——application/vnd.ms-excel 打開Word——application/msword 打開CHM——application/x-chm 打開文本txt——text/plain 打開PDF——application/pdf 打開VCF——text/x-vcard 打開SWF——flash/*
轉載于:https://blog.51cto.com/2960629/723493
總結
以上是生活随笔為你收集整理的Intent打开各种类型的文件的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 大学专业分类(大学共有多少专业)
 - 下一篇: SkGradientShader::Cr