Android进入本地文件管理器及不同文件查看
来源:互联网 发布:程序员个人简介 编辑:程序博客网 时间:2024/06/07 03:01
1、进入本地文件(添加文件):
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
//显示文件管理器列表
try {
startActivityForResult(Intent.createChooser(intent, "请选择一个要上传的文件"),FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(ProposalActivity.this, "请安装文件管理器", Toast.LENGTH_SHORT).show();
}
查看不同类型文件:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(“文件路径”);
if(“文件类型”.equals("pdf")){
//使用指定工具打开,参数为工具包名和打开页面的Activity。无改代码时,弹出可打开该文件的工具列表。
intent.setClassName("com.ebensz.pdf", "com.ebensz.pdf.pdfsign.droid.PdfViewerActivity");
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
}else{
Toast.makeText(FileGridActivity.this, "不支持该文件!", Toast.LENGTH_SHORT).show();
return;
}
startActivity(intent);
文件对应类型列表:
//{后缀名,MIME类型}
{".3gp", "video/3gpp"},
{".apk", "application/vnd.android.package-archive"},
{".asf", "video/x-ms-asf"},
{".avi", "video/x-msvideo"},
{".bin", "application/octet-stream"},
{".bmp", "image/bmp"},
{".c", "text/plain"},
{".class", "application/octet-stream"},
{".conf", "text/plain"},
{".cpp", "text/plain"},
{".doc", "application/msword"},
{".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
{".xls", "application/vnd.ms-excel"},
{".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
{".exe", "application/octet-stream"},
{".gif", "image/gif"},
{".gtar", "application/x-gtar"},
{".gz", "application/x-gzip"},
{".h", "text/plain"},
{".htm", "text/html"},
{".html", "text/html"},
{".jar", "application/java-archive"},
{".java", "text/plain"},
{".jpeg", "image/jpeg"},
{".jpg", "image/jpeg"},
{".js", "application/x-javascript"},
{".log", "text/plain"},
{".m3u", "audio/x-mpegurl"},
{".m4a", "audio/mp4a-latm"},
{".m4b", "audio/mp4a-latm"},
{".m4p", "audio/mp4a-latm"},
{".m4u", "video/vnd.mpegurl"},
{".m4v", "video/x-m4v"},
{".mov", "video/quicktime"},
{".mp2", "audio/x-mpeg"},
{".mp3", "audio/x-mpeg"},
{".mp4", "video/mp4"},
{".mpc", "application/vnd.mpohun.certificate"},
{".mpe", "video/mpeg"},
{".mpeg", "video/mpeg"},
{".mpg", "video/mpeg"},
{".mpg4", "video/mp4"},
{".mpga", "audio/mpeg"},
{".msg", "application/vnd.ms-outlook"},
{".ogg", "audio/ogg"},
{".pdf", "application/pdf"},
{".png", "image/png"},
{".pps", "application/vnd.ms-powerpoint"},
{".ppt", "application/vnd.ms-powerpoint"},
{".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
{".prop", "text/plain"},
{".rc", "text/plain"},
{".rmvb", "audio/x-pn-realaudio"},
{".rtf", "application/rtf"},
{".sh", "text/plain"},
{".tar", "application/x-tar"},
{".tgz", "application/x-compressed"},
{".txt", "text/plain"},
{".wav", "audio/x-wav"},
{".wma", "audio/x-ms-wma"},
{".wmv", "audio/x-ms-wmv"},
{".wps", "application/vnd.ms-works"},
{".xml", "text/plain"},
{".z", "application/x-compress"},
{".zip", "application/x-zip-compressed"},
{"", "*/*"}
- Android进入本地文件管理器及不同文件查看
- MT6737m进入手机的文件管理器中查看录音文件时的权限异常解决方法
- Android 文件管理器 Android文件管理器源代码
- 文件管理器-打开不同格式的文件
- Android学习-文件管理器
- Android 文件管理器
- android简易文件管理器
- 文件管理器-android源代码
- Android 文件管理器
- android OI文件管理器
- android 文件管理器
- 开源 android 文件管理器
- Android文件管理器
- Android文件管理器
- 文件管理器,根据不同文件类型,设…
- 获取本地文件列表及预览文件
- 查看文件的不同diff
- Android HttpClient及连接管理器
- Java数据转换整理
- WireShark 过滤语法
- Career Choices You Will Regret In 20 Years
- 亿级Web系统搭建——单机到分布式集群
- Sybase 还原过程中遇到的问题 20141219
- Android进入本地文件管理器及不同文件查看
- YII2 GridView联表搜索,排序
- Mac环境下服务器环境搭建
- 使用fiddler抓安卓APP数据包并调试PHP程序
- Android textView字体自定义结合HTml
- Princeton Algorithms: Part 2 [week 7: Final Exam Part II]
- PHP控制中奖概率的抽奖算法
- 获取对象中字段的get和set方法
- Magento添加Facebook/Pinterest open graph meta,Google商店Feed