當前位置: 首頁>>代碼示例>>Java>>正文


Java CustomTabsClient類代碼示例

本文整理匯總了Java中android.support.customtabs.CustomTabsClient的典型用法代碼示例。如果您正苦於以下問題:Java CustomTabsClient類的具體用法?Java CustomTabsClient怎麽用?Java CustomTabsClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CustomTabsClient類屬於android.support.customtabs包,在下文中一共展示了CustomTabsClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: warm

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
private Warmer warm(){
    mCustomTabServiceConnection =
            new CustomTabsServiceConnection() {
                @Override
                public void onCustomTabsServiceConnected(ComponentName componentName,
                                                         CustomTabsClient customTabsClient) {
                    mCustomTabsClient = customTabsClient;
                    mCustomTabsClient.warmup(0);
                    mCustomTabsSession = mCustomTabsClient.newSession(null);
                }

                @Override
                public void onServiceDisconnected(ComponentName name) {
                    mCustomTabsClient = null;
                }
            };

    packageNameToUse = ChromePackageHelper.getPackageNameToUse(context);

    if (packageNameToUse != null){
        CustomTabsClient.bindCustomTabsService(context, packageNameToUse,
                mCustomTabServiceConnection);
    }
    return this;
}
 
開發者ID:theblixguy,項目名稱:AutoScrollr,代碼行數:26,代碼來源:CustomTabs.java

示例2: bindCustomTabsService

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/**
 * Binds the Activity to the Custom Tabs Service.
 *
 * @param activity the activity to be binded to the service.
 */
public final void bindCustomTabsService(Activity activity)
{
  if (client != null)
  {
    return;
  }

  final String packageName = CustomTabsHelper.getPackageNameToUse(activity);
  if (packageName == null)
  {
    return;
  }

  connection = new ServiceConnection(this);
  CustomTabsClient.bindCustomTabsService(activity, packageName, connection);
}
 
開發者ID:Azure,項目名稱:azure-mobile-engagement-app-android,代碼行數:22,代碼來源:CustomTabActivityHelper.java

示例3: createSession

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/**
 * Creates a {@link android.support.customtabs.CustomTabsSession custom tab session} for
 * use with a custom tab intent, with optional callbacks and optional list of URIs that may
 * be requested. The URI list should be ordered such that the most likely URI to be requested
 * is first. If no custom tab supporting browser is available, this will return {@code null}.
 */
@WorkerThread
@Nullable
public CustomTabsSession createSession(
        @Nullable CustomTabsCallback callbacks,
        @Nullable Uri... possibleUris) {
    CustomTabsClient client = getClient();
    if (client == null) {
        return null;
    }

    CustomTabsSession session = client.newSession(callbacks);

    if (possibleUris != null && possibleUris.length > 0) {
        List<Bundle> additionalUris = UriUtil.toCustomTabUriBundle(possibleUris, 1);
        session.mayLaunchUrl(possibleUris[0], null, additionalUris);
    }

    return session;
}
 
開發者ID:openid,項目名稱:AppAuth-Android,代碼行數:26,代碼來源:CustomTabManager.java

示例4: bindService

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/**
 * Binds the Activity to the Custom Tabs Service.
 * @param context the context to be binded to the service.
 * @param origin the origin for the website that will be opened in the TWA.
 */
public void bindService(Context context, Uri origin) {
    if (mClient != null) {
        if (!origin.equals(mOrigin)) {
            throw new IllegalArgumentException(
                    "Trying to bind to a different origin. Should call unbindService first");
        }
        // If Service is already bound, just fire the callback.
        TwaSessionCallback twaSessionCallback = mTwaSessionCallback.get();
        if (twaSessionCallback != null) twaSessionCallback.onTwaSessionReady();
        return;
    }

    this.mOrigin = origin;
    this.packageName = CustomTabsClient.getPackageName(
            context, CHROME_PACKAGES, false);

    Context applicationContext = context.getApplicationContext();

    mConnection = new ServiceConnection(this);
    CustomTabsClient.bindCustomTabsService(applicationContext, packageName, mConnection);
}
 
開發者ID:GoogleChrome,項目名稱:custom-tabs-client,代碼行數:27,代碼來源:TwaSessionHelper.java

示例5: getChromePackages

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
private static List<String> getChromePackages(Context ctx) {
    CustomTabsServiceConnection conn = new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) {
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
        }
    };

    String[] packages = {"com.android.chrome", "com.chrome.beta", "com.chrome.dev"};
    List<String> availablePkgs = new ArrayList<>();

    for (String pkg : packages) {
        if (CustomTabsClient.bindCustomTabsService(ctx, pkg, conn)) {
            availablePkgs.add(pkg);
        }
    }

    return availablePkgs;
}
 
開發者ID:pumpkinz,項目名稱:pumpkin-reader,代碼行數:23,代碼來源:ActionUtil.java

示例6: warm

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
private Warmer warm(){
    mCustomTabServiceConnection =
            new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName,
                                                 CustomTabsClient customTabsClient) {
            mCustomTabsClient = customTabsClient;
            mCustomTabsClient.warmup(0);
            mCustomTabsSession = mCustomTabsClient.newSession(null);
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            mCustomTabsClient = null;
        }
    };

    packageNameToUse = ChromePackageHelper.getPackageNameToUse(context);

    if (packageNameToUse != null){
        CustomTabsClient.bindCustomTabsService(context, packageNameToUse,
                mCustomTabServiceConnection);
    }
    return this;
}
 
開發者ID:eliseomartelli,項目名稱:SimpleCustomTabs,代碼行數:26,代碼來源:CustomTabs.java

示例7: onCreate

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mCustomTabsServiceConnection = new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) {
            mClient = customTabsClient;
            mClient.warmup(0L);
            mCustomTabsSession = mClient.newSession(null);
        }
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mClient = null;
        }
    };
    CustomTabsClient.bindCustomTabsService(MainActivity.this, CUSTOM_TAB_PACKAGE_NAME, mCustomTabsServiceConnection);
    customTabsIntent = new CustomTabsIntent.Builder(mCustomTabsSession)
            .setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
            .setShowTitle(true)
            .build();
}
 
開發者ID:MJonesDev,項目名稱:CustomTabsTutorial,代碼行數:25,代碼來源:MainActivity.java

示例8: onCustomTabsServiceConnected

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
@Override
public void onCustomTabsServiceConnected(ComponentName componentName,
                                         CustomTabsClient customTabsClient) {

    tabsClient = customTabsClient;
    tabsClient.warmup(0);

    tabsSession = tabsClient.newSession(navCallbackReference.get());

    if (tabsSession != null && clientAuthUrl != null) {
        tabsSession.mayLaunchUrl(Uri.parse(clientAuthUrl), null, null);
    }

    AuthenticationCallback callback = authCallbackReference.get();
    if (callback != null) {
        callback.onReadyToAuthenticate(null);
    }
}
 
開發者ID:birdcage,項目名稱:soundcloud-web-api-android,代碼行數:19,代碼來源:AuthTabServiceConnection.java

示例9: onCustomTabsServiceConnected

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
@Override
public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) {

    if (customTabsClient != null) {
        customTabsClient.warmup(0L);

        // Create a new session
        mCustomTabsSession = customTabsClient.newSession(null);

        // Let the session know that it may launch a URL soon
        if (!TextUtils.isEmpty(mWebsiteUrl)) {
            Uri uri = Uri.parse(mWebsiteUrl);
            if (uri != null && mCustomTabsSession != null) {

                // If this returns true, custom tabs will work,
                // otherwise, you need another alternative if you don't want the user
                // to be launched out of the app by default
                mCustomTabsSession.mayLaunchUrl(uri, null, null);
            }
        }
    }
}
 
開發者ID:aknkaplanoglu,項目名稱:Sportmix,代碼行數:23,代碼來源:CustomTabServiceController.java

示例10: bindCustomTabsServiceTo

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
public void bindCustomTabsServiceTo(@NonNull final Context context, ServiceConnectionCallback callback) {
    if (isConnected()) {
        return;
    }

    serviceConnection = new ServiceConnection(callback);
    availableAppProvider.findBestPackage(
            new AvailableAppProvider.PackageFoundCallback() {
                @Override
                public void onPackageFound(String packageName) {
                    CustomTabsClient.bindCustomTabsService(context, packageName, serviceConnection);
                }

                @Override
                public void onPackageNotFound() {
                    serviceConnection = null;
                }
            }, context
    );
}
 
開發者ID:novoda,項目名稱:simple-chrome-custom-tabs,代碼行數:21,代碼來源:Binder.java

示例11: onActivityCreated

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsServiceConnection connection = new NewsCustomTabsServiceConnection();
    isCustomTabsSupported = isChromeCustomTabsSupported(getContext());
    setHasOptionsMenu(true);
    mListView = getListView();
    builder = new CustomTabsIntent.Builder();
    share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    builder.setToolbarColor(0x3E50B4);
    builder.setStartAnimations(getContext(),
            android.support.design.R.anim.abc_popup_enter,
            android.support.design.R.anim.abc_popup_exit);

    CustomTabsClient.bindCustomTabsService(getContext(),
            NewsCustomTabsServiceConnection.CUSTOM_TAB_PACKAGE_NAME, connection);
    addNews();
}
 
開發者ID:pennlabs,項目名稱:penn-mobile-android,代碼行數:20,代碼來源:NewsFragment.java

示例12: preload

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/** Caller must unbind the returned ServiceConnection when leaving the scope. */
public static @CheckResult @Nullable ServiceConnection preload(final Context context, final Uri uri, final @Nullable OnSessionReadyListener listener) {
	final CustomTabsServiceConnection connection;
	if (! CustomTabsClient.bindCustomTabsService(context, KChromePackageName, connection = new CustomTabsServiceConnection() {

		@Override public void onCustomTabsServiceConnected(final ComponentName componentName, final CustomTabsClient client) {
			Log.d(TAG, "Warming up Chrome custom tabs");
			if (client.warmup(0)) {
				final CustomTabsSession session = client.newSession(null);
				if (session != null) {
					session.mayLaunchUrl(uri, null, null);
					if (listener != null) listener.onSessionReady(session);
				}
			}
		}

		@Override public void onServiceDisconnected(final ComponentName name) {}
	})) return null;
	return connection;
}
 
開發者ID:oasisfeng,項目名稱:deagle,代碼行數:21,代碼來源:WebContent.java

示例13: bindCustomTabsService

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/**
 * Binds the Activity to the Custom Tabs Service.
 * @param activity the activity to be binded to the service.
 */
public void bindCustomTabsService(Activity activity) {
    if (mClient != null) return;

    String packageName = CustomTabsHelper.getPackageNameToUse(activity);
    if (packageName == null) return;

    mConnection = new ServiceConnection(this);
    CustomTabsClient.bindCustomTabsService(activity, packageName, mConnection);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:CustomTabActivityHelper.java

示例14: bindCustomTabsService

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
/**
 * Binds the Activity to the Custom Tabs Service.
 *
 * @param activity the activity to be binded to the service.
 */
public void bindCustomTabsService(Activity activity) {
  if (mClient != null) return;

  String packageName = CustomTabsHelper.getPackageNameToUse(activity);
  if (packageName == null) return;

  mConnection = new ServiceConnection(this);
  CustomTabsClient.bindCustomTabsService(activity, packageName, mConnection);
}
 
開發者ID:tomoya92,項目名稱:android-apps,代碼行數:15,代碼來源:CustomTabActivityHelper.java

示例15: bindCustomTabsService

import android.support.customtabs.CustomTabsClient; //導入依賴的package包/類
public void bindCustomTabsService() {
    if (mClient != null) return;
    if (mConnection == null) {
        mConnection = new ServiceConnection(this);
    }
    boolean ok = CustomTabsClient.bindCustomTabsService(mContext, CUSTOM_TAB_PACKAGE_NAME, mConnection);
}
 
開發者ID:faruktoptas,項目名稱:news-mvp,代碼行數:8,代碼來源:ChromeTabsWrapper.java


注:本文中的android.support.customtabs.CustomTabsClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。