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
這裏,因爲它不是一個意圖。