<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.ckt.fileproviderservice" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepath" /> </provider> android:name --- 定义名子 android:authorities --定义authority android:exported="false" 对其它应用不可用 android:grantUriPermissions="true" 既然对其它应用不可用,只能授予content uri临时权限 <meta-data>中的 android:name="android.support.FILE_PROVIDER_PATHS" (这个名子是固定的)和 android:resource 指向一个xml文件,这个xml文件定义了要共享文件的路径 xml/filepath.xml <paths> <files-path name="my_images" path="image/" /> <external-path name="my_external" /> <cache-path name="my_cache" /> </paths> <files-path> 指向的是内部存储要共享的目录 <external-path> 指向外部存储要共享的目录 <cache-path> 指向缓存要共享的目录 其中name为我们自己定义 的名子,path为具体的路径 如果请求一个default_image.jpg的 content uri,FileProvider返回的content URI是这样的 content://com.ckt.fileproviderservice/my_images/default_image.jpg 你确定提供路径的APP android:exported="false" 对其它应用不可用 是否设置了其他程序可用? 你的应用有获取权限? http://blog.csdn.net/zwlove5280/article/details/50509224
引用 2 楼 ink_s 的回复:http://blog.csdn.net/dj0379/article/details/50765021哎呀,弄错了。我想打开这个网页看看的,结果给发回复了,好尴尬。。。
http://blog.csdn.net/dj0379/article/details/50765021
80,492
社区成员
91,381
社区内容
加载中
试试用AI创作助手写篇文章吧