[英]Content:// and File:// in android when sharing pictures and videos
Both these are used by different apps. 这两个都由不同的应用程序使用。 Facebook shared with File Uris and Whatsapp with Content Uris.
Facebook与File Uris共享,Whatsapp与Content Uris共享。 If my app can share Videos and pictures, which one should I use?
如果我的应用程序可以共享视频和图片,我应该使用哪一个?
Also, if my app should accept videos and pictures, for which type should I be prepared? 另外,如果我的应用程序可以接受视频和图片,那么我应该准备哪种类型的视频? And if for both, should I convert the Content URI into a File Uri or the other way around?
如果两者都适用,我是否应该将Content URI转换为File Uri或以其他方式转换?
If my app can share Videos and pictures, which one should I use?
如果我的应用程序可以共享视频和图片,我应该使用哪一个?
On Android 7.0+, you have little choice but to share using a content
Uri
, such as from FileProvider
. 在Android 7.0+上,您别无选择,只能使用
content
Uri
进行共享,例如从FileProvider
。
On Android 6.0 and older, if the content is on internal storage, you also have to use FileProvider
, as third-party apps have no access to your portion of internal storage. 在Android 6.0及
FileProvider
版本上,如果内容位于内部存储中,则您还必须使用FileProvider
,因为第三方应用程序无法访问您的内部存储部分。 If the content is on external storage, you could use either file
or content
. 如果内容在外部存储器上,则可以使用
file
或content
。 The older the device, the more likely it is that pre-installed apps will only support file
. 设备越旧,预安装的应用程序仅支持
file
可能性就越大。
if my app should accept videos and pictures, for which type should I be prepared?
如果我的应用程序应该接受视频和图片,那么我应该准备哪种类型?
Ideally, both. 理想情况下,两者。 If by "accept" you mean via
ACTION_SEND
, you have no choice but to support both. 如果您通过
ACTION_SEND
表示“接受”,则别无选择,只能支持两者。 For ACTION_VIEW
and Intent
actions like it, where the data facet of an Intent
is used for the Uri
, use the <data>
element to advertise which scheme(s) you support. 对于
ACTION_VIEW
和Intent
像它的动作,其中一个的数据面Intent
被用于Uri
,可使用<data>
元素做广告你支持的方案(一个或多个)。
should I convert the Content URI into a File Uri or the other way around?
我应该将Content URI转换成File Uri还是反过来?
Neither. 都不行 You consume the content from its original source.
您从原始来源消费内容。 A
ContentProvider
supports both schemes, for things like getType()
and openInputStream()
. ContentProvider
支持两种方案,例如getType()
和openInputStream()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.