android调用自带文件选择器获取指定文件,编写解析Uri获取文件绝对路径

标题有点长,不多说 Intent intent=new Intent(Intent.ACTION_GET_CONTENT);intent.setType("textplain");intent.addCategory(

标题有点长,不多说

   Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("text/plain");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        startActivityForResult(intent,REC_REQUESTCODE);

其中“text/plain”是文件的后缀名所对应的MIME类型
当指定两种或两种以上指定文件类型格式是:

//intent.setType("video/*;image/*");//同时选择视频和图片

随手贴上常用的MIME类型

//{后缀名,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"}, 
{
  

发布者:admin,转转请注明出处:http://www.yc00.com/web/1733947264a3734454.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信