I want to add an action button to ChromeCustomTabs' toolbar so I followed this tutorial
The button is added but, instead of appearing in the toolbar, it appears at the bottom of the activity:
This is the code I use to create the Chrome Custom Tab:
private static void openUrlInChromeCustomTab(String webUrl, Activity activity, Item item) {
if (!(webUrl.startsWith("http:") || webUrl.startsWith("https:"))) {
webUrl = "http://" + webUrl;
}
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
Bitmap largeIcon = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_share);
Product product = (Product) item;
PendingIntent pendingIntent;
Intent intent = new Intent();
intent.setClass(activity, SharingDummyActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable(SharingDummyActivity.PRODUCT_CRITERIA, product);
intent.putExtras(bundle);
pendingIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent ,true);
builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent);
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(activity, Uri.parse(webUrl));
}
How do I get the action button inside the toolbar close to the three dots? Am I missing something?
Let, you open chrome custom tab from "MainActivity" and there is a option menu item "Close" in chrome custom tab, and on "Close" menu item click you want to close chrome custom tab and to go back the "MainActivity", then you can do it by starting "MainActivity".
Custom Tabs is a browser feature, introduced by Chrome, that is now supported by most major browsers on Android. It gives apps more control over their web experience, and makes transitions between native and web content more seamless without having to resort to a WebView.
Problem was that Chrome Custom Tabs only accepts 24/48 dp bitmaps, mine was higher. Just after changing the resource file by another with the accepted resolution, it worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With