仅限Facebook,Gmail和Twitter的ACTION_SEND。 Android的

时间:2011-11-23 04:14:08

标签: android android-intent

我正在使用ACTION_SEND Intent通过facebook,twitter和gmail分享Android市场应用程序网址链接。但是当我按下分享按钮时,其他选项也会出现像短信,电子邮件等。我只想出现Facebook,Twitter和gamil。有没有办法过滤它。

感谢。

3 个答案:

答案 0 :(得分:0)

您可以在设备上获取已安装应用程序的列表,并检查您要查找的应用程序是否已安装。然后为用户提供一个选项,通过

选择他想要分享的应用程序
List<ApplicationInfo> packages = getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo appInfo : packages) {
    if ("com.facebook.katana".equals(appInfo.packageName)) {
        // Facebook app is installed, add to options list
    }

    // Do something similar for Twitter and Gmail
}

// Show user the options list

答案 1 :(得分:0)

您可以通过

获取支持ACTION_SEND的已安装应用程序列表
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    List activities = getPackageManager().queryIntentActivities(sharingIntent, 0);

现在你可以通过检查这些应用程序是否在列表中来构建一个只包含所需应用程序的自定义对话框。

请在意图中传递类名称对话框的特定应用程序

答案 2 :(得分:0)

我发现这个解决方案让我工作得很完美。 http://www.gaanza.com/blog/email-client-intent-android/ 感谢。