CronetUtil
public final class CronetUtil
Cronet utility methods.
Summary
Public methods |
|
|---|---|
static @Nullable CronetEngine |
buildCronetEngine(Context context)Builds a |
static @Nullable CronetEngine |
@UnstableApiBuilds a |
Public methods
buildCronetEngine
public static @Nullable CronetEngine buildCronetEngine(Context context)
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 DefaultHttpDataSource than it is to use CronetDataSource with a fallback CronetEngine.
Note that it's recommended for applications to create only one instance of CronetEngine, 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 | |
|---|---|
@Nullable CronetEngine |
The |
buildCronetEngine
@UnstableApi
public static @Nullable CronetEngine buildCronetEngine(
Context context,
@Nullable String userAgent,
boolean preferGooglePlayServices
)
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 DefaultHttpDataSource than it is to use CronetDataSource with a fallback CronetEngine.
Note that it's recommended for applications to create only one instance of CronetEngine, 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. |
@Nullable String userAgent |
A default user agent, or |
boolean preferGooglePlayServices |
Whether Cronet from Google Play Services should be preferred over Cronet Embedded, if both are available. |
| Returns | |
|---|---|
@Nullable CronetEngine |
The |