`
univasity
  • 浏览: 808826 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Android 获取指向Resource的URI[转]

阅读更多

>> Uri真强大,还能这么搞...收藏了,回头要好好研究下~~

 

原文链接http://hi.baidu.com/zhoutianyang/blog/item/1a4d56df5979551f485403de.html

 

A Uri object can be used to reference a resource in an APK file. The Uri should be one of the following formats:

  • android.resource://package_name/id_number
    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
    id_number is the int form of the ID.
    The easiest way to construct this form is
    Uri uri = Uri.parse("android.resource://com.example.myapp/" + R.raw.my_resource");
    
    
  • android.resource://package_name/type/name
    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
    type is the string form of the resource type. For example, raw or drawable . name is the string form of the resource name. That is, whatever the file name was in your res directory, without the type extension. The easiest way to construct this form is
    Uri uri = Uri.parse("android.resource://com.example.myapp/raw/my_resource");
    
    
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics