void OpenCustomTab()
        {
            string url = mUrlEditText.Text;

            int color          = GetColor(mCustomTabColorEditText);
            int secondaryColor = GetColor(mCustomTabSecondaryColorEditText);

            CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
            intentBuilder.SetToolbarColor(color);
            intentBuilder.SetSecondaryToolbarColor(secondaryColor);

            if (mShowActionButtonCheckbox.Checked)
            {
                //Generally you do not want to decode bitmaps in the UI thread. Decoding it in the
                //UI thread to keep the example short.
                string        actionLabel   = GetString(Resource.String.label_action);
                Bitmap        icon          = BitmapFactory.DecodeResource(Resources, Android.Resource.Drawable.IcMenuShare);
                PendingIntent pendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_ACTION_BUTTON);
                intentBuilder.SetActionButton(icon, actionLabel, pendingIntent);
            }

            if (mAddMenusCheckbox.Checked)
            {
                string        menuItemTitle         = GetString(Resource.String.menu_item_title);
                PendingIntent menuItemPendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_MENU_ITEM);
                intentBuilder.AddMenuItem(menuItemTitle, menuItemPendingIntent);
            }

            if (mAddDefaultShareCheckbox.Checked)
            {
                intentBuilder.AddDefaultShareMenuItem();
            }

            if (mToolbarItemCheckbox.Checked)
            {
                //Generally you do not want to decode bitmaps in the UI thread. Decoding it in the
                //UI thread to keep the example short.
                string        actionLabel   = GetString(Resource.String.label_action);
                Bitmap        icon          = BitmapFactory.DecodeResource(Resources, Android.Resource.Drawable.IcMenuShare);
                PendingIntent pendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_TOOLBAR);
                intentBuilder.AddToolbarItem(TOOLBAR_ITEM_ID, icon, actionLabel, pendingIntent);
            }

            intentBuilder.SetShowTitle(mShowTitleCheckBox.Checked);

            if (mAutoHideAppBarCheckbox.Checked)
            {
                intentBuilder.EnableUrlBarHiding();
            }

            if (mCustomBackButtonCheckBox.Checked)
            {
                intentBuilder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));
            }
            intentBuilder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);
            intentBuilder.SetExitAnimations(this, Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);

            CustomTabActivityHelper.OpenCustomTab(
                this, intentBuilder.Build(), Uri.Parse(url), new WebviewFallback());
        }
コード例 #2
0
        void PrepareActionButton(CustomTabsIntent.Builder builder)
        {
            // An example intent that sends an email.
            Intent actionIntent = new Intent(Intent.ActionSend);

            actionIntent.SetType("*/*");
            actionIntent.PutExtra(Intent.ExtraEmail, "*****@*****.**");
            actionIntent.PutExtra(Intent.ExtraSubject, "example");
            PendingIntent pi   = PendingIntent.GetActivity(this, 0, actionIntent, 0);
            Bitmap        icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_share);

            builder.SetActionButton(icon, "send email", pi, true);
        }
コード例 #3
0
        void prepareActionButton(CustomTabsIntent.Builder builder)
        {
            // An example intent that sends an email.
            var actionIntent = new Intent(Intent.ActionSend);

            actionIntent.SetType("*/*");
            actionIntent.PutExtra(Intent.ExtraEmail, "*****@*****.**");
            actionIntent.PutExtra(Intent.ExtraSubject, "example");
            var pi   = PendingIntent.GetActivity(ApplicationContext, 0, actionIntent, 0);
            var icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon);

            builder.SetActionButton(icon, "send email", pi);
        }