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


Java CustomTabsClient.getPackageName方法代碼示例

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


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

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

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

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

示例4: ChromeTabsSoundCloudAuthenticator

import android.support.customtabs.CustomTabsClient; //導入方法依賴的package包/類
/**
 * Creates a {@link SoundCloudAuthenticator} that launches a Chrome Custom Tab to handle authentication.
 *
 * @param clientId          Client ID of the application requesting authorization.
 * @param redirectUri       Redirect URI of the application requesting authorization
 * @param context           Activity from which authentication is being launched.
 */
public ChromeTabsSoundCloudAuthenticator(String clientId, String redirectUri, Activity context) {
    super(clientId, redirectUri);

    this.context = context;
    this.browserPackageName = CustomTabsClient.getPackageName(context, null);
}
 
開發者ID:birdcage,項目名稱:soundcloud-web-api-android,代碼行數:14,代碼來源:ChromeTabsSoundCloudAuthenticator.java


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