本文整理汇总了Java中org.chromium.customtabsclient.shared.CustomTabsHelper类的典型用法代码示例。如果您正苦于以下问题:Java CustomTabsHelper类的具体用法?Java CustomTabsHelper怎么用?Java CustomTabsHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CustomTabsHelper类属于org.chromium.customtabsclient.shared包,在下文中一共展示了CustomTabsHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openCustomTab
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
*
* @param activity The host activity.
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available.
* @param uri the Uri to be opened.
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available.
*/
public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent,
Uri uri,
CustomTabFallback fallback) {
String 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) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
}
}
示例2: openCustomTab
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView
*
* @param activity The host activity
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
* @param uri the Uri to be opened
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
*/
public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent,
Uri uri,
CustomTabFallback fallback) {
String 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) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
}
}
示例3: launchCustomTabsWithSlide
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithSlide(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent.Builder builder =
new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setStartAnimations(this, R.anim.customtabs_in_slide_anim, R.anim.application_out_slide_anim)
.setExitAnimations(this, R.anim.application_in_slide_anim, R.anim.customtabs_out_slide_anim)
;
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例4: launchCustomTabsWithModal
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithModal(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent.Builder builder =
new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setStartAnimations(this, R.anim.customtabs_in_modal_anim, R.anim.application_out_modal_anim)
.setExitAnimations(this, R.anim.application_in_modal_anim, R.anim.customtabs_out_modal_anim)
;
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例5: launchCustomTabsWithBottomBar
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithBottomBar(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
Intent broadcastIntent = new Intent(this, BottombarBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 110, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int[] ids = {R.id.twitter, R.id.line, R.id.facebook};
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setSecondaryToolbarViews(createBottomBarRemoteView(), ids, pendingIntent)
.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例6: launchCustomTabsWithTransparent
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithTransparent(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
// This is a dummy
int[] ids = {0};
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setSecondaryToolbarViews(createTransparentRemoteView(), ids, null)
.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例7: launchCustomTabs
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabs(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
Intent snsIntent = new Intent(this, SessionBroadcastReceiver.class);
PendingIntent snsPendingIntent = PendingIntent.getBroadcast(this, 121, snsIntent, PendingIntent.FLAG_UPDATE_CURRENT);
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(session)
.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setActionButton(ResourceUtil.createBitmap(SessionActivity.this, icons[0]), "SNS", snsPendingIntent)
.addMenuItem("toggle", createRemoteViewPendingIntent(this))
.setSecondaryToolbarViews(SessionBroadcastReceiver.createRemoteView(), ids, null)
.build();
customTabsIntent.intent.setPackage(packageName);
CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例8: launchCustomTabsWithSessionBottombar
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
public void launchCustomTabsWithSessionBottombar(Activity activity, String url, @Nullable CustomTabsSession session) {
String packageName = CustomTabsHelper.getPackageNameToUse(activity);
if (TextUtils.isEmpty(packageName)) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
CustomTabsIntent.Builder builder;
if (session == null) {
builder = new CustomTabsIntent.Builder();
} else {
builder = new CustomTabsIntent.Builder(session);
}
// Intent hacked
Intent cctIntent = new CustomTabsIntent.Builder(session).build().intent;
cctIntent.setData(Uri.parse(url));
PendingIntent cctPendingIntent = PendingIntent.getActivity(activity, 124, cctIntent, PendingIntent.FLAG_UPDATE_CURRENT);
addSessionBottombar(builder, activity, cctPendingIntent);
CustomTabsIntent customTabsIntent = builder
.setToolbarColor(Color.WHITE)
.build();
CustomTabsHelper.addKeepAliveExtra(activity, customTabsIntent.intent);
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, Uri.parse(url));
}
示例9: launchCustomTabs
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabs(@NonNull String url, @ColorRes int colorRes) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent.Builder builder =
new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(this, colorRes))
.setActionButton(ResourceUtil.createBitmap(this, R.drawable.ic_android_pink_500), "sample", createActivityPendingIntent(12), true)
.setShowTitle(true)
;
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.intent.putExtra(EXTRA_ENABLE_URLBAR_HIDING, false);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例10: launchCustomTabsWithMenuItem
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithMenuItem(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent.Builder builder =
new CustomTabsIntent.Builder()
.addMenuItem("copy1", createServicePendingIntent(21))
.addMenuItem("copy2", createServicePendingIntent(22))
.addMenuItem("share1", createBroadcastPendingIntent(23))
.addMenuItem("share2", createBroadcastPendingIntent(24))
.addMenuItem("home1", createActivityPendingIntent(25))
.addMenuItem("home2", createActivityPendingIntent(26)) // Not displayed.
.addDefaultShareMenuItem()
.setCloseButtonIcon(ResourceUtil.createBitmap(this, R.drawable.ic_android_pink_500))
;
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例11: openCustomTab
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
*
* @param activity The host activity.
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available.
* @param uri the Uri to be opened.
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available.
*/
public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent,
Uri uri,
CustomTabFallback fallback) {
String 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) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
}
}
示例12: show
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void show(String url, @ColorInt int toolbarColor, boolean showDefaultShareMenuItem, String transition) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession())
.setToolbarColor(toolbarColor);
if(showDefaultShareMenuItem)
builder.addDefaultShareMenuItem();
if(!TextUtils.isEmpty(transition))
addTransition(builder, transition);
CustomTabsIntent customTabsIntent = builder.build();
String packageName = CustomTabsHelper.getPackageNameToUse(cordova.getActivity());
if ( packageName != null ) {
customTabsIntent.intent.setPackage(packageName);
}
startCustomTabActivity(url, customTabsIntent.intent);
}
开发者ID:EddyVerbruggen,项目名称:cordova-plugin-safariviewcontroller,代码行数:19,代码来源:ChromeCustomTabPlugin.java
示例13: bindCustomTabsService
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的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);
mConnection = new org.chromium.customtabsclient.shared.ServiceConnection(this);
CustomTabsClient.bindCustomTabsService(activity, packageName, mConnection);
}
示例14: launchCustomTabsWithHeader
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithHeader(String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
customTabsIntent.intent.setPackage(packageName);
Bundle headers = new Bundle();
headers.putString("header1", "value1");
headers.putString("header2", "value2");
customTabsIntent.intent.putExtra(Browser.EXTRA_HEADERS, headers);
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例15: launchCustomTabsWithReferrer
import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入依赖的package包/类
private void launchCustomTabsWithReferrer(Context context, String url) {
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (TextUtils.isEmpty(packageName)) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return;
}
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
Uri.parse("android-app://" + context.getPackageName()));
customTabsIntent.launchUrl(context, Uri.parse(url));
}