【问题标题】:how can I make user able to share app using more than one communication app?如何使用户能够使用多个通信应用程序共享应用程序?
【发布时间】:2023-11-30 16:00:01
【问题描述】:

当我使用以下代码时,用户只需一次选择一个通讯应用程序(例如 WhatsApp),即可分享应用程序链接。 下次默认选择此通讯应用,用户无法选择其他通讯应用。

public static void shareApp(Context context) {
final String appPackageName = context.getPackageName();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Check cool App at:" +"https://play.google.com/store/apps/details?id=" + appPackageName);
sendIntent.setType("text/plain");
context.startActivity(sendIntent);
}

【问题讨论】:

  • 欢迎来到 SO。这个问题已经被问过很多次了,所以你可能很快就会被否决,但我在下面为你回答了。下次,请先尝试更多地使用 Google 搜索!

标签: android hyperlink share communication sharing


【解决方案1】:

你想使用选择器意图:

String title = "Your Chooser Title"
context.startActivity(Intent.createChooser(sendIntent, title));

【讨论】: