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


Java CustomTabsClient.bindCustomTabsService方法代碼示例

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


在下文中一共展示了CustomTabsClient.bindCustomTabsService方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: onCreateOptionsMenu

import android.support.customtabs.CustomTabsClient; //導入方法依賴的package包/類
@SuppressLint("RestrictedApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (menu instanceof MenuBuilder) {
        ((MenuBuilder) menu).setOptionalIconsVisible(true);
    }
    String packageName = CustomTabsClient.getPackageName(this, null);
    CustomTabsClient.bindCustomTabsService(this, !TextUtils.isEmpty(packageName) ? packageName : "com.android.chrome", chromeConnection);
    getMenuInflater().inflate(R.menu.hass, menu);
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:Maxr1998,項目名稱:home-assistant-Android,代碼行數:12,代碼來源:HassActivity.java

示例13: onCreate

import android.support.customtabs.CustomTabsClient; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String packageName = CustomTabsClient.getPackageName(this, null);
    CustomTabsClient.bindCustomTabsService(this, !TextUtils.isEmpty(packageName) ? packageName : "com.android.chrome", chromeConnection);
}
 
開發者ID:Maxr1998,項目名稱:home-assistant-Android,代碼行數:15,代碼來源:SettingsActivity.java

示例14: bindService

import android.support.customtabs.CustomTabsClient; //導入方法依賴的package包/類
public void bindService(Context context) {
    try {
        CustomTabsClient.bindCustomTabsService(context,
                "com.android.chrome",
                customTabsServiceConnection);
    } catch (Exception e) {
    }
}
 
開發者ID:akexorcist,項目名稱:Android-SleepingForLess,代碼行數:9,代碼來源:ExternalBrowserUtility.java

示例15: 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:indywidualny,項目名稱:Centrum.fm,代碼行數:15,代碼來源:CustomTabActivityHelper.java


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