如何让用户能够使用多个通信应用程序共享应用程序



当我使用以下代码时,用户只需一次即可选择一个通信应用程序(例如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);
}

你想使用选择器意图:

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

最新更新