“android.intent.extra.STREAM”
在进行一些研发时发现了代码使用以下语句
Uri uri = (Uri) getIntent().getExtras().get("android.intent.extra.STREAM");
我扫描了整个项目以查找该活动是否是从任何其他活动调用的,但没有找到任何。谁能告诉我这个语句会返回什么以及代码中的语句 "android.intent.extra.STREAM"
做什么,它是否是一个常量,如果是的话它的值是什么?
提前致谢。
快乐编码
While doing some R&D I found a code using the following statement
Uri uri = (Uri) getIntent().getExtras().get("android.intent.extra.STREAM");
I have scanned the whole project to find whether the activity was called from any other activity, but did'nt find any. Can any one tell me what will this statement return and what is the statement "android.intent.extra.STREAM"
doing in the code, whether it is a constant, if yes what is its value?
Thanks in advance.
Happy Coding
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此语句将返回名为
"android.intent.extra.STREAM"
的额外内容。无论哪个活动发出意图,都会设置该值,并且如果不查看数据的使用方式或在何处/如何设置,则无法简单地判断该数据是什么。不要忘记意图可以由任何活动或应用程序发出。找到你的答案:
所以,我认为这是设计用于共享图像的意图的不良编码(使用值而不是定义的静态常量)的结果。 Intent 包含
Intent.EXTRA_STREAM
extra 作为要共享的图像(在本例中)的数据流。 IMO,代码应该是:但无论如何,它似乎是将二进制数据流附加到意图的记录/标准化方法。
持续的研究似乎表明它添加了 Campyre(Campfire 客户端)作为“共享”选项。因此,在图库中,如果您选择共享图像,Campyre 将显示为选项之一。
Google 和 Android 开发者网站 是您的朋友。我总共花了大约 2 分钟才获得所有这些信息。不需要输入回复和后续编辑...
更多详细说明:
这是 AndroidManifest.xml 中的相关部分:
这表明 Activity 可以处理用于共享项目所在位置的 Intents共享的是图像。
This statement will return the extra named
"android.intent.extra.STREAM"
. Whatever activity issued the intent set that value, and there's no easy way to tell what that data is without seeing how it is used, or where/how it was set. Don't forget that the intent could be issued by any activity or application.Found your answer:
So, I would posit that it's the result of poor coding (using the value rather than the defined static constant) for an intent designed to share images. The intent includes the
Intent.EXTRA_STREAM
extra as the data stream for the image (in this case) to be shared. IMO, the code should have been:But regardless, it appears to be the documented/standardized way of attaching a binary datastream to an intent.
Continued research seems to indicate that it adds Campyre (a Campfire client) as a "Share" option. So from Gallery, if you choose to Share an image, Campyre shows up as one of the options.
Google and the Android dev site are your friends. It took me all of about 2 minutes total to get all that information. Not as long as it took to type the replies and subsequent edits...
More elaboration:
Here is the relevant section from
AndroidManifest.xml
:Which indicates that the Activity can handle Intents for sharing where the item being shared is an image.