【发布时间】:2023-03-27 04:35:01
【问题描述】:
我想使用 CustomTabs 库,我需要在其中添加一个 share 菜单项。该库仅接受将 PendingIntent 实例用作菜单项的 Action。我想使用以下代码确保在没有 Just Once 和 Always 按钮的情况下始终向用户建议该列表:
Intent shareIntent = Intent.createChooser(intent, "Choose the application to share.");
但现在的问题是,如果我使用此选择器 Intent 创建 PendingIntent,Chrome 的 CustomTabs 不会为用户启动选择器:
PendingIntent pendingIntent = PendingIntent.getActivity(context,
requestCode,
shareIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
有没有办法将选择器的 Intent 用作 PendingIntent?
我不能使用以下行来启动 Intent,因为库是这样做的,它只接受 PendingIntents:
startActivity(Intent.createChooser(i, getString()));
【问题讨论】:
标签: android android-pendingintent chrome-custom-tabs share-intent