Beispiel #1
0
        /// <summary>
        /// Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
        /// </summary>
        /// <param name="activity"> The host activity. </param>
        /// <param name="custom_tabs_intent"> a CustomTabsIntent to be used if Custom Tabs is available. </param>
        /// <param name="uri"> the Uri to be opened. </param>
        /// <param name="fallback"> a CustomTabFallback to be used if Custom Tabs is not available. </param>
        public /*static*/ void LaunchUrlWithCustomTabsOrFallback
        (
            Activity activity,
            CustomTabsIntent custom_tabs_intent,
            Uri uri,
            ICustomTabFallback fallback
        )
        {
            string packageName = PackageManagerHelper.GetPackageNameToUse(activity, uri.ToString());

            //If we cant find a package name, it means theres no browser that supports
            //Chrome Custom Tabs installed. So, we fallback to the webview
            if (packageName == null)
            {
                if (fallback != null)
                {
                    fallback.OpenUri(activity, uri);
                }
            }
            else
            {
                custom_tabs_intent.Intent.SetPackage(packageName);
                custom_tabs_intent.LaunchUrl(activity, uri);
            }

            return;
        }
Beispiel #2
0
        /// <summary>
        /// Launches a Chrome custom tab to the specified url
        /// </summary>
        /// <param name="url">The url to launch in a Chrome custom tab</param>
        private void LaunchBrowser(string url)
        {
            CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
            CustomTabsIntent         customTabsIntent = builder.Build();

            customTabsIntent.LaunchUrl(AndroidContext, global::Android.Net.Uri.Parse(url));
        }
Beispiel #3
0
        /// <summary>
        /// Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
        /// </summary>
        /// <param name="activity"> The host activity. </param>
        /// <param name="customTabsIntent"> a CustomTabsIntent to be used if Custom Tabs is available. </param>
        /// <param name="uri"> the Uri to be opened. </param>
        /// <param name="fallback"> a CustomTabFallback to be used if Custom Tabs is not available. </param>
        public static void OpenCustomTab
        (
            Activity activity,
            CustomTabsIntent customTabsIntent,
            Android.Net.Uri uri,
            ICustomTabFallback fallback
        )
        {
            string packageName = Org.Chromium.CustomTabsClient.Shared.CustomTabsHelper.GetPackageNameToUse(activity);

            //If we cant find a package name, it means theres no browser that supports
            //Chrome Custom Tabs installed. So, we fallback to the webview
            if (packageName == null)
            {
                if (fallback != null)
                {
                    fallback.OpenUri(activity, uri);
                }
            }
            else
            {
                customTabsIntent.Intent.SetPackage(packageName);
                customTabsIntent.LaunchUrl(activity, uri);
            }
        }
Beispiel #4
0
        /// <inheritdoc/>
        public void OpenWebsiteInApp(string url)
        {
            // Use the Android custom tabs to display the webpage inside the app.
            CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
            CustomTabsIntent         customTabsIntent = builder.Build();

            customTabsIntent.LaunchUrl(_applicationContext, Uri.Parse(url));
        }
            public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest request)
            {
                CustomTabsIntent.Builder builder   = new CustomTabsIntent.Builder();
                CustomTabsIntent         customTab = builder.Build();

                customTab.LaunchUrl(view.Context, request.Url);

                return(true);
            }
Beispiel #6
0
        public Task <string> LoginAsync()
        {
            TaskCompletionSource = new TaskCompletionSource <string>();

            string url = "https://oauthdemo.000webhostapp.com/test.html?" +
                         "scope=email%20profile&" +
                         "response_type=code&" +
                         "redirect_uri=com.companyname.xamarinformsauth%3A/oauth2redirect&" +
                         "client_id=1056433391892-gboradv67bghftbf41iee3q5ueflp6gb.apps.googleusercontent.com";


            Intent             activityIntent       = new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://oauthdemo.000webhostapp.com/test.html"));
            PackageManager     pm                   = CrossCurrentActivity.Current.Activity.PackageManager;
            List <ResolveInfo> resolvedActivityList = pm.QueryIntentActivities(
                activityIntent, PackageInfoFlags.MatchAll).ToList();

            foreach (var info in resolvedActivityList)
            {
                Intent serviceIntent = new Intent();
                serviceIntent.SetAction("android.support.customtabs.action.CustomTabsService");
                serviceIntent.SetPackage(info.ActivityInfo.PackageName);
                if (pm.ResolveService(serviceIntent, 0) != null)
                {
                    System.Diagnostics.Debug.WriteLine($"{info.ActivityInfo.PackageName} supports custom tabs");
                }
            }



            var ok = CustomTabsClient.BindCustomTabsService(Android.App.Application.Context, "org.mozilla.firefox", new MyServiceConnection((c) =>
            {
                client = c;

                var session = client.NewSession(new CallBackHandler((e, b) =>
                {
                    System.Diagnostics.Debug.WriteLine(e);
                }));



                CustomTabsIntent.Builder builder  = new CustomTabsIntent.Builder(session);
                CustomTabsIntent customTabsIntent = builder.Build();
                TrustedWebUtils.LaunchAsTrustedWebActivity(CrossCurrentActivity.Current.Activity, customTabsIntent, Android.Net.Uri.Parse(url));
                //customTabsIntent.LaunchUrl(Android.App.Application.Context, Android.Net.Uri.Parse(url));
            }));

            CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
            CustomTabsIntent         customTabsIntent = builder.Build();

            customTabsIntent.LaunchUrl(CrossCurrentActivity.Current.Activity, Android.Net.Uri.Parse(url));


            return(TaskCompletionSource.Task);
        }
Beispiel #7
0
 /// <summary>
 /// Open intent Browser From App using Url
 /// </summary>
 /// <param name="url"></param>
 public void OpenBrowserFromApp(string url)
 {
     try
     {
         CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
         CustomTabsIntent         customTabsIntent = builder.Build();
         customTabsIntent.Intent.AddFlags(ActivityFlags.NewTask);
         customTabsIntent.LaunchUrl(Context, Uri.Parse(url));
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 /// <summary>
 /// Open intent Browser From App using Url
 /// </summary>
 /// <param name="url"></param>
 public void OpenBrowserFromApp(string url)
 {
     try
     {
         CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
         CustomTabsIntent         customTabsIntent = builder.Build();
         customTabsIntent.Intent.AddFlags(ActivityFlags.NewTask);
         customTabsIntent.LaunchUrl(Context, Uri.Parse(url));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Beispiel #9
0
        public void OnClick(View view)
        {
            string url = mEditText.Text;
            bool   success;

            switch (view.Id)
            {
            case Resource.Id.connect_button:
                BindCustomTabsService();
                break;

            case Resource.Id.warmup_button:
                success = false;
                if (mClient != null)
                {
                    success = mClient.Warmup(0);
                }
                mWarmupButton.Enabled &= success;
                break;

            case Resource.Id.may_launch_button:
                CustomTabsSession session = GetSession();
                success = false;
                if (mClient != null)
                {
                    success = session.MayLaunchUrl(Uri.Parse(url), null, null);
                }
                mMayLaunchButton.Enabled &= success;
                break;

            case Resource.Id.launch_button:
                var builder = new CustomTabsIntent.Builder(GetSession());
                builder.SetToolbarColor(Color.ParseColor(TOOLBAR_COLOR)).SetShowTitle(true);
                PrepareMenuItems(builder);
                PrepareActionButton(builder);
                PrepareBottombar(builder);
                builder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);
                builder.SetExitAnimations(this, Resource.Animation.slide_in_left, Resource.Animation.slide_out_right);
                builder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));
                CustomTabsIntent customTabsIntent = builder.Build();
                CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent);
                customTabsIntent.LaunchUrl(this, Uri.Parse(url));
                break;
            }
        }
        public static void OpenCustomTab(Activity activity,
                                         CustomTabsIntent customTabsIntent,
                                         Uri uri,
                                         ICustomTabFallback fallback)
        {
            var packageName = CustomTabsHelper.GetPackageNameToUse(activity);

            //If we cant find a package name, it means theres no browser that supports
            //Chrome Custom Tabs installed. So, we fallback to the webview
            if (packageName == null)
            {
                fallback?.OpenUri(activity, uri);
            }
            else
            {
                customTabsIntent.Intent.SetPackage(packageName);
                customTabsIntent.LaunchUrl(activity, uri);
            }
        }
Beispiel #11
0
        void UseCustomTabsActivityManagerWithIntent()
        {
            // create & open chrome custom tab
            CustomTabsActivityManager mgr = new CustomTabsActivityManager(this);

            // build custom tab
            CustomTabsIntent.Builder builder = null;
            builder = new CustomTabsIntent.Builder(mgr.Session)
                      .SetToolbarColor(Android.Graphics.Color.Argb(255, 52, 152, 219))
                      .SetShowTitle(true)
                      .EnableUrlBarHiding();

            CustomTabsIntent customTabsIntent = builder.Build();

            // ensures the intent is not kept in the history stack, which makes
            // sure navigating away from it will close it
            customTabsIntent.Intent.AddFlags(Android.Content.ActivityFlags.NoHistory);
            customTabsIntent.LaunchUrl(this, Android.Net.Uri.Parse(url));

            return;
        }
        /// <summary>
        /// Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
        /// </summary>
        /// <param name="activity"> The host activity. </param>
        /// <param name="custom_tabs_intent"> a CustomTabsIntent to be used if Custom Tabs is available. </param>
        /// <param name="uri"> the Uri to be opened. </param>
        /// <param name="fallback"> a CustomTabFallback to be used if Custom Tabs is not available. </param>
        public /*static*/ void LaunchUrlWithCustomTabsOrFallback
        (
            Activity a,
            CustomTabsIntent custom_tabs_intent,
            string package_name_for_custom_tabs,
            Android.Net.Uri u,
            ICustomTabFallback fallback
        )
        {
            uri      = u;
            activity = a;
            bool fallback_neccessary = false;

            //If we cant find a package name, it means theres no browser that supports
            //Chrome Custom Tabs installed. So, we fallback to the webview
            if (package_name_for_custom_tabs == null)
            {
                fallback_neccessary = true;
            }
            else
            {
                custom_tabs_activity_manager = new CustomTabsActivityManager(this.activity);

                custom_tabs_activity_manager.BindService(package_name_for_custom_tabs);
                //custom_tabs_intent.Intent.SetPackage(package_name_for_custom_tabs);

                custom_tabs_session = custom_tabs_activity_manager.Session;

                custom_tabs_intent_builder = new CustomTabsIntent.Builder(custom_tabs_session);


                // direct call to CustomtTasIntent.LaunchUrl was ported from java samples and refactored
                // seems like API changed
                //------------------------------------------------------------------------------
                //custom_tabs_intent.LaunchUrl(activity, uri);
                //return;
                //------------------------------------------------------------------------------
                custom_tabs_activity_manager = new CustomTabsActivityManager(activity);
                custom_tabs_intent           = custom_tabs_intent_builder.Build();

                CustomTabsHelper.AddKeepAliveExtra(activity, custom_tabs_intent.Intent);

                custom_tabs_intent.LaunchUrl(activity, uri);
                custom_tabs_activity_manager.CustomTabsServiceConnected +=
                    // custom_tabs_activit_manager_CustomTabsServiceConnected
                    delegate
                {
                    System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager.CustomTabsServiceConnected");

                    custom_tabs_activity_manager.LaunchUrl(uri.ToString());

                    System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager.LaunchUrl");

                    return;
                }
                ;
                System.Diagnostics.Debug.WriteLine($"CustomTabsActivityManager.BindService({package_name_for_custom_tabs})");
                service_bound = custom_tabs_activity_manager.BindService(package_name_for_custom_tabs);
                //custom_tabs_activity_manager.LaunchUrl(uri.ToString());
                //------------------------------------------------------------------------------

                if (service_bound == false)
                {
                    System.Diagnostics.Debug.WriteLine($"FALLBACK: No Packages that support CustomTabs");
                    // No Packages that support CustomTabs
                    fallback_neccessary = true;
                }
            }

            if (fallback_neccessary == true && fallback != null)
            {
                fallback.OpenUri(activity, uri);
            }

            return;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            paymentRequestDetailsListener = new PaymentRequestDetailsListener
            {
                PaymentMethodSelectionRequired = (paymentRequest, recurringMethods, otherMethods, callback) =>
                {
                    PaymentMethodSelectionFragment paymentMethodSelectionFragment
                        = new PaymentMethodSelectionFragmentBuilder()
                          .SetPaymentMethods(new List <PaymentMethod>(otherMethods))
                          .SetPreferredPaymentMethods(new List <PaymentMethod>(recurringMethods))
                          .SetPaymentMethodSelectionListener(new PaymentMethodSelectionListener
                    {
                        PaymentMethodSelected = (paymentMethod) =>
                        {
                            callback.CompletionWithPaymentMethod(paymentMethod);
                        }
                    })
                          .Build();
                    SupportFragmentManager.BeginTransaction().Replace(Android.Resource.Id.Content, paymentMethodSelectionFragment).AddToBackStack(null).CommitAllowingStateLoss();
                },
                RedirectRequired = (paymentRequest, redirectUrl, returnUriCallback) =>
                {
                    uriCallback = returnUriCallback;
                    CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
                    CustomTabsIntent         customTabsIntent = builder.Build();
                    customTabsIntent.LaunchUrl(context, Android.Net.Uri.Parse(redirectUrl));
                },

                //
                PaymentDetailsRequired = (paymentRequest, inputDetails, callback) =>
                {
                    var paymentMethodType = paymentRequest.PaymentMethod.GetType();

                    if (PaymentMethod.Type.Card.Equals(paymentMethodType))
                    {
                        CreditCardFragment creditCardFragment = new CreditCardFragmentBuilder()
                                                                .SetPaymentMethod(paymentRequest.PaymentMethod)
                                                                .SetPublicKey(paymentRequest.PublicKey)
                                                                .SetGenerationtime(paymentRequest.GenerationTime)
                                                                .SetAmount(paymentRequest.Amount)
                                                                .SetShopperReference(paymentRequest.ShopperReference)
                                                                .SetCreditCardInfoListener(new CreditCardInfoListener
                        {
                            CreditCardInfoProvided = (p0) =>
                            {
                                callback.CompletionWithPaymentDetails(p0);
                            }
                        })
                                                                .Build();

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Android.Resource.Id.Content, creditCardFragment).AddToBackStack(null)
                        .CommitAllowingStateLoss();
                    }
                    else if (PaymentMethod.Type.Ideal.Equals(paymentMethodType))
                    {
                        IssuerSelectionFragment issuerSelectionFragment = new IssuerSelectionFragmentBuilder()
                                                                          .SetPaymentMethod(paymentRequest.PaymentMethod)
                                                                          .SetIssuerSelectionListener(new IssuerSelectionListener
                        {
                            IssuerSelected = (p0) =>
                            {
                                IdealPaymentDetails idealPaymentDetails = new IdealPaymentDetails(inputDetails);
                                idealPaymentDetails.FillIssuer(p0);
                                callback.CompletionWithPaymentDetails(idealPaymentDetails);
                            }
                        })

                                                                          .Build();

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Android.Resource.Id.Content, issuerSelectionFragment).AddToBackStack(null)
                        .CommitAllowingStateLoss();
                    }
                    else if (PaymentMethod.Type.SepaDirectDebit.Equals(paymentMethodType))
                    {
                        SepaDirectDebitFragment sepaDirectDebitFragment = new SepaDirectDebitFragmentBuilder()
                                                                          .SetAmount(paymentRequest.Amount)
                                                                          .SetSEPADirectDebitPaymentDetailsListener(new SEPADirectDebitPaymentDetailsListener
                        {
                            PaymentDetails = (iban, accountHolder) =>
                            {
                                SepaDirectDebitPaymentDetails sepaDirectDebitPaymentDetails = new SepaDirectDebitPaymentDetails(inputDetails);
                                sepaDirectDebitPaymentDetails.FillIban(iban);
                                sepaDirectDebitPaymentDetails.FillOwner(accountHolder);
                                callback.CompletionWithPaymentDetails(sepaDirectDebitPaymentDetails);
                            }
                        })
                                                                          .Build();

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Android.Resource.Id.Content, sepaDirectDebitFragment).AddToBackStack(null)
                        .CommitAllowingStateLoss();
                    }
                    else
                    {
                        Toast.MakeText(this, "UI for " + paymentMethodType + " has not been implemented.", ToastLength.Long).Show();
                        paymentRequest.Cancel();
                    }
                }
            };

            context = this;
            Android.Net.Uri uri = Intent.Data;
            if (uri == null)
            {
                setupInitScreen();
            }
            else
            {
                //throw new IllegalStateException("Application was supposed to be declared singleTask");
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            paymentRequestDetailsListener = new PaymentRequestDetailsListener
            {
                PaymentMethodSelectionRequired = (paymentRequest, recurringMethods, otherMethods, callback) =>
                {
                    paymentMethodCallback = callback;
                    preferredPaymentMethods.Clear();
                    preferredPaymentMethods.AddRange(recurringMethods);
                    availablePaymentMethods.Clear();
                    availablePaymentMethods.AddRange(otherMethods);
                    PaymentMethodSelectionFragment paymentMethodSelectionFragment = new PaymentMethodSelectionFragment();
                    SupportFragmentManager.BeginTransaction().Replace(Android.Resource.Id.Content, paymentMethodSelectionFragment).AddToBackStack(null).CommitAllowingStateLoss();
                },
                RedirectRequired = (paymentRequest, redirectUrl, returnUriCallback) =>
                {
                    Log.Debug(TAG, "paymentRequestDetailsListener.onRedirectRequired(): " + redirectUrl);
                    uriCallback = returnUriCallback;
                    CustomTabsIntent.Builder builder          = new CustomTabsIntent.Builder();
                    CustomTabsIntent         customTabsIntent = builder.Build();
                    customTabsIntent.LaunchUrl(context, Android.Net.Uri.Parse(redirectUrl));
                },
                PaymentDetailsRequired = (paymentRequest, inputDetails, callback) =>
                {
                    Log.Debug(TAG, "paymentRequestDetailsListener.onPaymentDetailsRequired()");
                    String paymentMethodType = paymentRequest.PaymentMethod.GetType();

                    if (PaymentMethod.Type.Card.Equals(paymentMethodType))
                    {
                        CreditCardFragment creditCardFragment = new CreditCardFragment();
                        Bundle             bundle             = new Bundle();
                        //ONE CLICK CHECK
                        bool isOneClick = InputDetailsUtil.ContainsKey(inputDetails, "cardDetails.cvc");
                        if (isOneClick)
                        {
                            bundle.PutBoolean("oneClick", true);
                        }
                        creditCardFragment.setCreditCardInfoListener(new CreditCardInfoListener
                        {
                            CreditCardInfoProvided = (creditCardInfo) =>
                            {
                                if (isOneClick)
                                {
                                    CVCOnlyPaymentDetails cvcOnlyPaymentDetails = new CVCOnlyPaymentDetails(inputDetails);
                                    cvcOnlyPaymentDetails.FillCvc(creditCardInfo);
                                    callback.CompletionWithPaymentDetails(cvcOnlyPaymentDetails);
                                }
                                else
                                {
                                    CreditCardPaymentDetails creditCardPaymentDetails = new CreditCardPaymentDetails(inputDetails);
                                    creditCardPaymentDetails.FillCardToken(creditCardInfo);
                                    callback.CompletionWithPaymentDetails(creditCardPaymentDetails);
                                }
                            }
                        });
                        bundle.PutString("public_key", paymentRequest.PublicKey);
                        bundle.PutString("generation_time", paymentRequest.GenerationTime);
                        creditCardFragment.Arguments = bundle;

                        SupportFragmentManager.BeginTransaction().Replace(Android.Resource.Id.Content,
                                                                          creditCardFragment).AddToBackStack(null).CommitAllowingStateLoss();
                    }
                    else if (PaymentMethod.Type.Ideal.Equals(paymentMethodType))
                    {
                        AlertDialog.Builder     alertDialog       = new AlertDialog.Builder(this);
                        List <InputDetail.Item> issuers           = InputDetailsUtil.GetInputDetail(inputDetails, "idealIssuer").Items as List <InputDetail.Item>;
                        IssuerListAdapter       issuerListAdapter = new IssuerListAdapter(this, issuers);
                        alertDialog.SetSingleChoiceItems(issuerListAdapter, -1, new OnClickListener
                        {
                            Click = (dialogInterface, i) =>
                            {
                                IdealPaymentDetails idealPaymentDetails = new IdealPaymentDetails(inputDetails);
                                idealPaymentDetails.FillIssuer(issuers[i]);
                                dialogInterface.Dismiss();
                                callback.CompletionWithPaymentDetails(idealPaymentDetails);
                            }
                        });
                        alertDialog.Show();
                    }
                    else
                    {
                        String message = "UI for " + paymentMethodType + " has not been implemented.";
                        Log.Warn(TAG, message);
                        Toast.MakeText(this, message, ToastLength.Long).Show();
                        paymentRequest.Cancel();
                    }
                }
            };
            paymentRequestListener = new PaymentRequestListener
            {
                PaymentDataRequested = (paymentRequest, token, callback) =>
                {
                    Log.Debug(TAG, "paymentRequestListener.onPaymentDataRequested()");
                    Dictionary <string, string> headers = new Dictionary <string, string>();
                    headers.Add("Content-Type", "application/json; charset=UTF-8");
                    headers.Add(merchantApiHeaderKeyForApiSecretKey, merchantApiSecretKey);
                    AsyncHttpClient.Post(merchantServerUrl + SETUP, headers, getSetupDataString(token), new HttpResponseCallback
                    {
                        Success = (response) =>
                        {
                            callback.CompletionWithPaymentData(response);
                        },
                        Failure = (e) =>
                        {
                            Log.Error(TAG, "HTTP Response problem: ", e);
                            paymentRequest.Cancel();
                        }
                    });
                },
                PaymentResult = (paymentRequest, paymentResult) =>
                {
                    Log.Debug(TAG, "paymentRequestListener.onPaymentResult()");
                    String resultString;
                    if (paymentResult.IsProcessed)
                    {
                        resultString = paymentResult.Payment.GetPaymentStatus().ToString();
                        verifyPayment(paymentResult.Payment);
                    }
                    else
                    {
                        resultString = paymentResult.Error.ToString();
                    }

                    Intent intent = new Intent(ApplicationContext, typeof(PaymentResultActivity));
                    intent.PutExtra("Result", resultString);
                    intent.AddFlags(ActivityFlags.ClearTop);
                    intent.AddFlags(ActivityFlags.NewTask);
                    StartActivity(intent);
                    Finish();
                }
            };
            Log.Debug(TAG, "onCreate()");
            context = this;
            Android.Net.Uri uri = Intent.Data;
            if (uri == null)
            {
                setupInitScreen();
            }
            else
            {
                throw new Java.Lang.IllegalStateException("Application was supposed to be declared singleTask");
            }
        }
Beispiel #15
0
        public void OnClick(View v)
        {
            string url    = mEditText.Text.ToString();
            int    viewId = v.Id;

            if (viewId == Resource.Id.connect_button)
            {
                BindCustomTabsService();
            }
            else if (viewId == Resource.Id.warmup_button)
            {
                bool success = false;
                if (custom_tabs_client != null)
                {
                    success = custom_tabs_client.Warmup(0);
                }
                if (!success)
                {
                    mWarmupButton.Enabled = false;
                }
            }
            else if (viewId == Resource.Id.may_launch_button)
            {
                CustomTabsSession session = Session;
                bool success = false;
                if (custom_tabs_client != null)
                {
                    success = session.MayLaunchUrl(Android.Net.Uri.Parse(url), null, null);
                }
                if (!success)
                {
                    mMayLaunchButton.Enabled = false;
                }
            }
            else if (viewId == Resource.Id.launch_button)
            {
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(Session);
                builder.SetToolbarColor(Color.ParseColor(TOOLBAR_COLOR)).SetShowTitle(true);
                PrepareMenuItems(builder);
                PrepareActionButton(builder);
                PrepareBottomBar(builder);

                builder.SetStartAnimations
                (
                    this,
                    Resource.Animation.slide_in_right,
                    Resource.Animation.slide_out_left
                );
                builder.SetExitAnimations
                (
                    this,
                    Android.Resource.Animation.SlideInLeft,
                    Android.Resource.Animation.SlideOutRight
                );
                builder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));


                CustomTabsIntent customTabsIntent = builder.Build();
                // derived class used - thus FQNS
                HolisticWare.Android.Support.CustomTabs.Chromium.SharedUtilities.
                CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent);

                try
                {
                    customTabsIntent.LaunchUrl(this, Android.Net.Uri.Parse(url));
                }
                catch (System.Exception exc)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("CustomTabsIntent.LaunchUrl Exception");
                }
                return;
            }
        }