android 文件关联 mimeType

android手机中经常看到用xx播放,用xxx浏览器,分享到xxx等.这种菜单

实现关键代码:

[html]  view plain  copy
 print ?
  1.         <activity android:name="com.ifeisu.browser.window.IFeiSuActivity"  
  2.             android:launchMode="singleInstance" android:label="@string/APP_NAME">  
  3.             <intent-filter>  
  4.                 <action android:name="android.intent.action.MAIN" />  
  5.                 <category android:name="android.intent.category.LAUNCHER" />  
  6.             </intent-filter>  
  7.             <intent-filter>  
  8.                     <!-- 用于拦截所有HTTP请求 -->  
  9.                                 <action android:name="android.intent.action.VIEW" />  
  10.                                 <category android:name="android.intent.category.DEFAULT" />  
  11.                                 <category android:name="android.intent.category.BROWSABLE" />  
  12.                                 <!--这个很重要,不然会拦截不到http请求-->  
  13.                                 <data android:scheme="http" android:host="*" />  
  14.                 <data android:mimeType="*/*" />  
  15.             </intent-filter>  
  16.         </activity>  

其中

[html]  view plain  copy
 print ?
  1. <data android:mimeType="*/*" />  
这个代表能打开所有文件,下面是一些常见文件的mimeType

[plain]  view plain  copy
 print ?
  1.   {".3gp", "video/3gpp"},  
  2. {".apk", "application/vnd.android.package-archive"},  
  3. {".asf", "video/x-ms-asf"},  
  4. {".avi", "video/x-msvideo"},  
  5. {".bin", "application/octet-stream"},  
  6. {".bmp", "image/bmp"},  
  7. {".c", "text/plain"},  
  8. {".class", "application/octet-stream"},  
  9. {".conf", "text/plain"},  
  10. {".cpp", "text/plain"},  
  11. {".doc", "application/msword"},  
  12. {".exe", "application/octet-stream"},  
  13. {".gif", "image/gif"},  
  14. {".gtar", "application/x-gtar"},  
  15. {".gz", "application/x-gzip"},  
  16. {".h", "text/plain"},  
  17. {".htm", "text/html"},  
  18. {".html", "text/html"},  
  19. {".jar", "application/java-archive"},  
  20. {".java", "text/plain"},  
  21. {".jpeg", "image/jpeg"},  
  22. {".jpg", "image/jpeg"},  
  23. {".js", "application/x-javascript"},  
  24. {".log", "text/plain"},  
  25. {".m3u", "audio/x-mpegurl"},  
  26. {".m4a", "audio/mp4a-latm"},  
  27. {".m4b", "audio/mp4a-latm"},  
  28. {".m4p", "audio/mp4a-latm"},  
  29. {".m4u", "video/vnd.mpegurl"},  
  30. {".m4v", "video/x-m4v"},  
  31. {".mov", "video/quicktime"},  
  32. {".mp2", "audio/x-mpeg"},  
  33. {".mp3", "audio/x-mpeg"},  
  34. {".mp4", "video/mp4"},  
  35. {".mpc", "application/vnd.mpohun.certificate"},  
  36. {".mpe", "video/mpeg"},  
  37. {".mpeg", "video/mpeg"},  
  38. {".mpg", "video/mpeg"},  
  39.      {".mpg4", "video/mp4"},  
  40. {".mpga", "audio/mpeg"},  
  41. {".msg", "application/vnd.ms-outlook"},  
  42. {".ogg", "audio/ogg"},  
  43. {".pdf", "application/pdf"},  
  44. {".png", "image/png"},  
  45. {".pps", "application/vnd.ms-powerpoint"},  
  46. {".ppt", "application/vnd.ms-powerpoint"},  
  47. {".prop", "text/plain"},  
  48. {".rar", "application/x-rar-compressed"},  
  49. {".rc", "text/plain"},  
  50. {".rmvb", "audio/x-pn-realaudio"},  
  51. {".rtf", "application/rtf"},  
  52. {".sh", "text/plain"},  
  53. {".tar", "application/x-tar"},  
  54. {".tgz", "application/x-compressed"},  
  55. {".txt", "text/plain"},  
  56. {".wav", "audio/x-wav"},  
  57. {".wma", "audio/x-ms-wma"},  
  58. {".wmv", "audio/x-ms-wmv"},  
  59. {".wps", "application/vnd.ms-works"},  
  60. //{".xml", "text/xml"},  
  61. {".xml", "text/plain"},  
  62. {".z", "application/x-compress"},  
  63. {".zip", "application/zip"},  
  64. {"", "*/*"}  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值