我正在尝试向ChromeCustomTabs添加新的菜单项以共享当前网址。
我知道我们可以添加默认
.addDefaultShareMenuItem()
到我们的CustomTabsIntent。但我不想用这个。
我也知道如何通过创建PendingIntent来添加菜单项,如: -
Intent urlIntent = new Intent();
String currentURL = urlIntent.getDataString();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
PendingIntent p = PendingIntent.getActivity(getBaseContext(), 123, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT);
现在,在我们的构建器中,我们将添加: -
.addMenuItem("Share Current Link", p);
代码有效,但返回空值而不是当前网址。
我不知道在Intent urlIntent = new Intent(/*what to put here to get customTabs intent*/)
放什么。
我们不能将customIntent
放在这里,因为它不是意图。