I am trying to add a new Menu Item to my ChromeCustomTabs for sharing the current url.
I know that we can add a default
.addDefaultShareMenuItem()
to our CustomTabsIntent. But I don't want to use this.
I also know how to add a menu item by creating a PendingIntent like :-
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);
Now in our builder we will be adding :-
.addMenuItem("Share Current Link", p);
The code works but return an empty value instead of the current URL.
I don't know what to put in Intent urlIntent = new Intent(/*what to put here to get customTabs intent*/)
.
We can't put our customIntent
here because it is not an Intent.