获取能够处理要在视图(不是弹出对话框)中显示的 SEND 意图的应用程序列表
我正在尝试获取手机上安装的能够处理发送意图的所有应用程序的列表。我目前正在使用 Intent.createChooser 处理这种情况,但这不是我想要实现的目标,因为我希望能够访问应用程序列表,以类似的方式在我的活动的视图中显示它们Android 图库应用程序如何显示它们而不是在旋转对话框中。
此处提供屏幕截图: https://i.sstatic.net/0dQmo.jpg
任何帮助都是非常感谢。
I'm trying to get the list of all apps installed on a phone capable of handling the SEND intent. I am currently handling this situation by using Intent.createChooser but this is not what I am trying to achieve as I would like to be able to get access to the list of apps to display them in a View in my activity, in a way similar to how the Android stock Gallery app displays them and NOT in a spinner dialog.
Screenshot available here: https://i.sstatic.net/0dQmo.jpg
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
PackageManager
上调用queryIntentActivities()
,给定一个ACTION_SEND
Intent
配置,与createChooser( 一起使用) )
(即具有 MIME 类型、Uri
等)。这将为您提供将出现在选择器中的所有匹配项的列表。然后,您可以利用用户的选择来启动实际的活动。这是一个示例项目,它使用它来创建主屏幕式发射器。
Call
queryIntentActivities()
onPackageManager
, given anACTION_SEND
Intent
configured as you would use withcreateChooser()
(i.e., has the MIME type,Uri
, etc.). This will give you a list of all the matches that would appear in the chooser. You can then make use of the user's selection to launch the actual activity.Here is a sample project that uses this to create a home screen-style launcher.