Java Code Examples for org.chromium.customtabsclient.shared.CustomTabsHelper#getPackageNameToUse()
The following examples show how to use
org.chromium.customtabsclient.shared.CustomTabsHelper#getPackageNameToUse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomTabActivityHelper.java From AndroidProjects with MIT License | 6 votes |
/** * 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); } }
Example 2
Source File: CustomTabActivityHelper.java From custom-tabs-client with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 3
Source File: ChromeCustomTabPlugin.java From cordova-plugin-safariviewcontroller with MIT License | 6 votes |
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); }
Example 4
Source File: CustomTabActivityHelper.java From AndroidProjects with MIT License | 5 votes |
/** * 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); }
Example 5
Source File: CustomTabActivityHelper.java From custom-tabs-client with Apache License 2.0 | 5 votes |
/** * 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); }
Example 6
Source File: MainActivity.java From custom-tabs-client with Apache License 2.0 | 5 votes |
private void bindCustomTabsService() { if (mClient != null) return; if (TextUtils.isEmpty(mPackageNameToBind)) { mPackageNameToBind = CustomTabsHelper.getPackageNameToUse(this); if (mPackageNameToBind == null) return; } mConnection = new ServiceConnection(this); boolean ok = CustomTabsClient.bindCustomTabsService(this, mPackageNameToBind, mConnection); if (ok) { mConnectButton.setEnabled(false); } else { mConnection = null; } }
Example 7
Source File: CustomTabServiceHelper.java From cordova-plugin-safariviewcontroller with MIT License | 4 votes |
public CustomTabServiceHelper(Context context){ mPackageNameToBind = CustomTabsHelper.getPackageNameToUse(context); }