Пример #1
0
        void BindCustomTabsService()
        {
            if (mClient != null)
            {
                return;
            }
            if (TextUtils.IsEmpty(mPackageNameToBind))
            {
                mPackageNameToBind = CustomTabsHelper.GetPackageNameToUse(this);
                if (mPackageNameToBind == null)
                {
                    return;
                }
            }
            mConnection = new ServiceConnection(this);
            bool ok = CustomTabsClient.BindCustomTabsService(this, mPackageNameToBind, mConnection);

            if (ok)
            {
                mConnectButton.Enabled = false;
            }
            else
            {
                mConnection = null;
            }
        }
        public void BindCustomTabsService(Activity activity)
        {
            if (mClient != null)
            {
                return;
            }

            var packageName = CustomTabsHelper.GetPackageNameToUse(activity);

            if (packageName == null)
            {
                return;
            }

            mConnection = new ServiceConnection(this);
            CustomTabsClient.BindCustomTabsService(activity, packageName, mConnection);
        }
        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);
            }
        }