本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}