PendingIntent 不创建意图选择器
PendingIntent does not create intent chooser
我正在使用 Chrome 自定义选项卡在我的应用程序中打开 URL。我正在尝试在其操作按钮中配置 Share
功能,该功能需要 PendingIntent 作为其参数之一。我按如下方式返回 PendingIntent:
private static PendingIntent getShareIntent(@NotNull Context context, @NotNull Uri uri)
{
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, uri.toString());
return PendingIntent
.getActivity(context, (int) System.currentTimeMillis(),
shareIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
问题是,当第一次点击分享按钮时,它会为 select 应用程序创建一个选择器(如下所示)以用于分享,但在第一次点击后不会这样做。这只显示一次。用户做出选择后,它将成为默认应用程序,所有后续点击共享按钮都会在应用程序 selected 中打开。我在返回 pendingIntent 时使用了 Intent.createChooser(shareIntent, "Share via")
,但无济于事。请帮忙。
事实证明,它不适用于 Samsung Note 3 Neo (SM-N750)。它适用于我测试过的 Nexus 设备。浪费了半天试图解决这个问题。这就是生活。
我正在使用 Chrome 自定义选项卡在我的应用程序中打开 URL。我正在尝试在其操作按钮中配置 Share
功能,该功能需要 PendingIntent 作为其参数之一。我按如下方式返回 PendingIntent:
private static PendingIntent getShareIntent(@NotNull Context context, @NotNull Uri uri)
{
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, uri.toString());
return PendingIntent
.getActivity(context, (int) System.currentTimeMillis(),
shareIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
问题是,当第一次点击分享按钮时,它会为 select 应用程序创建一个选择器(如下所示)以用于分享,但在第一次点击后不会这样做。这只显示一次。用户做出选择后,它将成为默认应用程序,所有后续点击共享按钮都会在应用程序 selected 中打开。我在返回 pendingIntent 时使用了 Intent.createChooser(shareIntent, "Share via")
,但无济于事。请帮忙。
事实证明,它不适用于 Samsung Note 3 Neo (SM-N750)。它适用于我测试过的 Nexus 设备。浪费了半天试图解决这个问题。这就是生活。