2016-12-16 30 views
1

我正在尝试将新的菜单项添加到我的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); 

代码工作,但返回空值而不是当前URL。

我不知道该放什么Intent urlIntent = new Intent(/*what to put here to get customTabs intent*/)。 我们不能把我们的customIntent这里,因为它不是一个意图。

回答

相关问题