在要求EXTRA

编程入门 行业动态 更新时间:2024-10-26 10:27:36
在要求EXTRA_ALLOW_MULTIPLE时,Google相册会返回逆序照片(Google Photos return inverse order photos when asking for EXTRA_ALLOW_MULTIPLE)

我要求图库应用中的图片:

Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

我正在读这样的结果:

ClipData clipData = data.getClipData(); Uri[] uris = new Uri[clipData.getItemCount()]; for (int i = 0; i < uris.length; i++) { uris[i] = clipData.getItemAt(i).getUri(); }

我注意到,当我使用Google相册作为图库时,结果的反转顺序与我在Google相册中选择的结果相反。

这是故意的,一致的还是有记录的?

I am asking for images from a gallery app with:

Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

I am reading the results like this:

ClipData clipData = data.getClipData(); Uri[] uris = new Uri[clipData.getItemCount()]; for (int i = 0; i < uris.length; i++) { uris[i] = clipData.getItemAt(i).getUri(); }

I noticed that when I use Google Photos as the gallery, the results come back in a reverse order to that I have selected in Google Photos' ui.

Is that intentional, consistent or documented anywhere?

最满意答案

首先, ACTION_PICK是错误的Intent动作。 如果您阅读了ACTION_PICK的文档 ,那就是从特定集合中挑选内容; MIME类型不是记录的输入值之一。 ACTION_GET_CONTENT用于根据MIME类型选择内容。

其次,请注意EXTRA_ALLOW_MULTIPLE用于ACTION_GET_CONTENT和ACTION_OPEN_DOCUMENT 。 因此,很少有ACTION_PICK实现会尊重额外的。

第三,不要求从EXTRA_ALLOW_MULTIPLE请求返回的Uri值具有任何特定顺序。 有数千种可能的应用程序会响应您的请求,他们可以按照他们希望的顺序向您发送结果。 特别是, EXTRA_ALLOW_MULTIPLE的文档没有解决顺序问题。

如果订单在您的应用中很重要,请构建您自己的UI以确认订单。 提供方便的一键“反向”选项,除了可能拖放以允许任意更改。 毕竟,在内容选择期间,用户可能没有意识到该顺序很重要,因此即使用户选择内容的顺序也不是用户的实际期望顺序。

First, ACTION_PICK is the wrong Intent action. If you read the documentation for ACTION_PICK, that is for picking content from a specific collection; MIME type is not one of the documented input values. ACTION_GET_CONTENT is for picking content based on a MIME type.

Second, note that EXTRA_ALLOW_MULTIPLE is for use with ACTION_GET_CONTENT and ACTION_OPEN_DOCUMENT. Hence, few ACTION_PICK implementations will honor that extra.

Third, there is no requirement for the Uri values returned from an EXTRA_ALLOW_MULTIPLE request to be in any particular order. There are thousands of possible apps that will respond to your request, and they can send you the results in whatever order they wish. In particular, the documentation for EXTRA_ALLOW_MULTIPLE does not address order.

If order matters in your app, build your own UI to confirm the order. Offer a convenient one-click "reverse" option, in addition to perhaps drag-and-drop to allow for arbitrary changes. After all, the user may not realize, during the content selection, that order matters, and so even the order in which the user chose the content is not the user's actual desired order.

更多推荐

本文发布于:2023-07-22 01:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215511.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EXTRA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!