class CronetUtil


Cronet utility methods.

Summary

Public functions

java-static CronetEngine?

Builds a CronetEngine suitable for use with CronetDataSource.

java-static CronetEngine?
@UnstableApi
buildCronetEngine(
    context: Context!,
    userAgent: String?,
    preferGooglePlayServices: Boolean
)

Builds a CronetEngine suitable for use with CronetDataSource.

Public functions

buildCronetEngine

java-static fun buildCronetEngine(context: Context!): CronetEngine?

Builds a CronetEngine suitable for use with CronetDataSource. When choosing a Cronet provider to build the CronetEngine, disabled providers are not considered. Neither are fallback providers, since it's more efficient to use than it is to use CronetDataSource with a fallback .

Note that it's recommended for applications to create only one instance of , so if your application already has an instance for performing other networking, then that instance should be used and calling this method is unnecessary. See the Android developer guide to learn more about using Cronet for network operations.

Parameters
context: Context!

A context.

Returns
CronetEngine?

The CronetEngine, or null if no suitable engine could be built.

buildCronetEngine

@UnstableApi
java-static fun buildCronetEngine(
    context: Context!,
    userAgent: String?,
    preferGooglePlayServices: Boolean
): CronetEngine?

Builds a CronetEngine suitable for use with CronetDataSource. When choosing a Cronet provider to build the CronetEngine, disabled providers are not considered. Neither are fallback providers, since it's more efficient to use than it is to use CronetDataSource with a fallback .

Note that it's recommended for applications to create only one instance of , so if your application already has an instance for performing other networking, then that instance should be used and calling this method is unnecessary. See the Android developer guide to learn more about using Cronet for network operations.

Parameters
context: Context!

A context.

userAgent: String?

A default user agent, or null to use a default user agent of the CronetEngine.

preferGooglePlayServices: Boolean

Whether Cronet from Google Play Services should be preferred over Cronet Embedded, if both are available.

Returns
CronetEngine?

The CronetEngine, or null if no suitable engine could be built.