如何知道哪些意图在Intent.ACTION_SEND选择? [英] How to know which intent is selected in Intent.ACTION_SEND?

查看:221
本文介绍了如何知道哪些意图在Intent.ACTION_SEND选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Android Intent.ACTION_SEND快速分享一些东西。所以我有一个共享列表如下:

I want to use Android Intent.ACTION_SEND for quickly sharing something. So I got a sharing list like this:

不过,我想分享不同的内容对每个动作,如:

But I want to share different content for each action, such as:

  • 如果通过电子邮件/ Gmail的共享,内容应该是分享通过电子邮件分享。

  • If sharing by Email/Gmail, content should be "Share by email".

如果通过Facebook的共享,内容应该是分享通过Facebook的。

If sharing by Facebook, content should be "Share by Facebook".

那么,是不是可以这样做呢?

So, is it possible to do that?

推荐答案

您无法获取这些信息。

除非你创建你自己的实现活动选择对话框。

Unless you create your own implementation of the dialog for the activity selection.

要创建你需要使用 PackageManager queryIntentActivities()等功能对话框。该函数返回名单,其中,ResolveInfo>

To create such dialog you need to use PackageManager and its queryIntentActivities() function. The function returns List<ResolveInfo>.

ResolveInfo 包含有关活动( resolveInfo.activityInfo.packageName ),并与帮助的一些信息 PackageManager 就可以得到其他的信息(用于显示在对话框中的活动) - 应用程序图标绘制,应用标签,...

ResolveInfo contains some information about an activity (resolveInfo.activityInfo.packageName), and with the help of PackageManager you can get other information (useful for displaying the activity in the dialog) - application icon drawable, application label, ... .

中显示结果列表在对话(或在风格作为对话的活动)。当一个项目被点击创建新Intent.ACTION_SEND,添加你想要的内容,并添加选定活动的包( intent.setPackage(包名称))。

Display the results in a list in a dialog (or in an activity styled as a dialog). When an item is clicked create new Intent.ACTION_SEND, add the content you want and add the package of the selected activity (intent.setPackage(pkgName)).

这篇关于如何知道哪些意图在Intent.ACTION_SEND选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆