Java Code Examples for android.support.customtabs.CustomTabsClient#warmup()

The following examples show how to use android.support.customtabs.CustomTabsClient#warmup() . 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: ManageDataLauncherActivity.java    From custom-tabs-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName componentName,
        CustomTabsClient client) {
    Uri uri = getUrlForManagingSpace();
    if (uri == null) {
        finish();
        return;
    }

    mSession = client.newSession(mCustomTabsCallback);
    if (mSession == null) {
        onError(new RuntimeException("Failed to create CustomTabsSession"));
        finish();
        return;
    }

    // Warm up is needed for origin verification.
    client.warmup(0);
    mSession.validateRelationship(RELATION_HANDLE_ALL_URLS, uri, null);
}
 
Example 2
Source File: TwaLauncher.java    From custom-tabs-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName componentName,
        CustomTabsClient client) {
    if (TrustedWebUtils.warmupIsRequired(mContext, mProviderPackage)) {
        client.warmup(0);
    }
    mSession = client.newSession(null, mSessionId);

    if (mSession != null && mOnSessionCreatedRunnable != null) {
        mOnSessionCreatedRunnable.run();
    } else if (mSession == null && mOnSessionCreationFailedRunnable != null) {
        mOnSessionCreationFailedRunnable.run();
    }

    mOnSessionCreatedRunnable = null;
    mOnSessionCreationFailedRunnable = null;
}
 
Example 3
Source File: HassActivity.java    From home-assistant-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) {
    client.warmup(0);
    customTabsSession = client.newSession(new CustomTabsCallback());
    if (customTabsSession == null) {
        return;
    }
    // Delay to not slow down native app loading
    communicationHandler.postDelayed(() -> customTabsSession.mayLaunchUrl(Uri.parse(Utils.getUrl(HassActivity.this)), null, null), 1500);
}
 
Example 4
Source File: SettingsActivity.java    From home-assistant-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) {
    client.warmup(0);
    customTabsSession = client.newSession(new CustomTabsCallback());
    if (customTabsSession == null) {
        return;
    }
    // Delay to not slow down native app loading
    customTabsSession.mayLaunchUrl(Uri.parse(Common.CROWDIN_URL), null, null);
}
 
Example 5
Source File: CustomTabsController.java    From Auth0.Android with MIT License 5 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) {
    if (customTabsClient == null) {
        return;
    }
    Log.d(TAG, "CustomTabs Service connected");
    customTabsClient.warmup(0L);
    session.set(customTabsClient.newSession(null));
    sessionLatch.countDown();
}
 
Example 6
Source File: CustomTabsHelper.java    From rides-android-sdk with MIT License 5 votes vote down vote up
/**
 * Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
 *
 * @param context The host context.
 * @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 void openCustomTab(
        final Context context,
        final CustomTabsIntent customTabsIntent,
        final Uri uri,
        CustomTabFallback fallback) {
    final String packageName = getPackageNameToUse(context);

    if (packageName != null) {
        connection = new CustomTabsServiceConnection() {
            @Override
            public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) {
                client.warmup(0L); // This prevents backgrounding after redirection

                customTabsIntent.intent.setPackage(packageName);
                customTabsIntent.intent.setData(uri);
                customTabsIntent.launchUrl(context, uri);
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {
            }
        };
        CustomTabsClient.bindCustomTabsService(context, packageName, connection);
    } else if (fallback != null) {
        fallback.openUri(context, uri);
    } else {
        Log.e(UberSdk.UBER_SDK_LOG_TAG, "Use of openCustomTab without Customtab support or a fallback set");
    }
}
 
Example 7
Source File: Browser.java    From OsmGo with MIT License 4 votes vote down vote up
@Override
public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) {
  customTabsClient = client;
  client.warmup(0);
}
 
Example 8
Source File: ChromeCustomTabPlugin.java    From cordova-plugin-safariviewcontroller with MIT License 4 votes vote down vote up
private boolean warmUp(){
    boolean success = false;
    final CustomTabsClient client = mCustomTabPluginHelper.getClient();
    if (client != null) success = client.warmup(0);
    return success;
}