public final class

UserAgentMetadata.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.webkit.UserAgentMetadata.Builder

Overview

Builder used to create UserAgentMetadata objects.

Examples:

  // Create a setting with default options.
  new UserAgentMetadata.Builder().build();

  // Create a setting with a brand version contains brand name: myBrand, major version: 100,
  // full version: 100.1.1.1.
  BrandVersion brandVersion = new BrandVersion.Builder().setBrand("myBrand")
                                                        .setMajorVersion("100")
                                                        .setFullVersion("100.1.1.1")
                                                        .build();
  new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
                                 .build();

  // Create a setting brand version, platform, platform version and bitness.
  new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
                                 .setPlatform("myPlatform")
                                 .setPlatform("1.1.1.1")
                                 .setBitness(BITNESS_64)
                                 .build();
 

Summary

Constructors
publicBuilder()

Create an empty UserAgentMetadata Builder.

publicBuilder(UserAgentMetadata uaMetadata)

Create a UserAgentMetadata Builder from an existing UserAgentMetadata object.

Methods
public UserAgentMetadatabuild()

Builds the current settings into a UserAgentMetadata object.

public UserAgentMetadata.BuildersetArchitecture(java.lang.String architecture)

Sets the user-agent metadata architecture.

public UserAgentMetadata.BuildersetBitness(int bitness)

Sets the user-agent metadata bitness, the default value is UserAgentMetadata.BITNESS_DEFAULT, which indicates an empty string for sec-ch-ua-bitness.

public UserAgentMetadata.BuildersetBrandVersionList(java.util.List<UserAgentMetadata.BrandVersion> brandVersions)

Sets user-agent metadata brands and their versions.

public UserAgentMetadata.BuildersetFullVersion(java.lang.String fullVersion)

Sets the user-agent metadata full version.

public UserAgentMetadata.BuildersetMobile(boolean mobile)

Sets the user-agent metadata mobile, the default value is true.

public UserAgentMetadata.BuildersetModel(java.lang.String model)

Sets the user-agent metadata model.

public UserAgentMetadata.BuildersetPlatform(java.lang.String platform)

Sets the user-agent metadata platform.

public UserAgentMetadata.BuildersetPlatformVersion(java.lang.String platformVersion)

Sets the user-agent metadata platform version.

public UserAgentMetadata.BuildersetWow64(boolean wow64)

Sets the user-agent metadata wow64, the default is false.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Create an empty UserAgentMetadata Builder.

public Builder(UserAgentMetadata uaMetadata)

Create a UserAgentMetadata Builder from an existing UserAgentMetadata object.

Methods

public UserAgentMetadata build()

Builds the current settings into a UserAgentMetadata object.

Returns:

The UserAgentMetadata object represented by this Builder

public UserAgentMetadata.Builder setBrandVersionList(java.util.List<UserAgentMetadata.BrandVersion> brandVersions)

Sets user-agent metadata brands and their versions. The brand name, major version and full version should not be blank. The default value is an empty list which means the system default user-agent metadata brands and versions will be used to generate the user-agent client hints.

Parameters:

brandVersions: a list of UserAgentMetadata.BrandVersion used to generated user-agent client hints sec-cu-ua and sec-ch-ua-full-version-list.

public UserAgentMetadata.Builder setFullVersion(java.lang.String fullVersion)

Sets the user-agent metadata full version. The full version should not be blank, even though the spec about brand full version could be empty. A blank full version could cause inconsistent brands when generating brand version related user-agent client hints. It also provides a bad experience for developers when processing the brand full version. If null is provided, the system default value will be used to generate the client hint.

Parameters:

fullVersion: The full version is used to generate user-agent client hint sec-ch-ua-full-version.

public UserAgentMetadata.Builder setPlatform(java.lang.String platform)

Sets the user-agent metadata platform. The platform should not be blank. If null is provided, the system default value will be used to generate the client hint.

Parameters:

platform: The platform is used to generate user-agent client hint sec-ch-ua-platform.

public UserAgentMetadata.Builder setPlatformVersion(java.lang.String platformVersion)

Sets the user-agent metadata platform version. If null is provided, the system default value will be used to generate the client hint.

Parameters:

platformVersion: The platform version is used to generate user-agent client hint sec-ch-ua-platform-version.

public UserAgentMetadata.Builder setArchitecture(java.lang.String architecture)

Sets the user-agent metadata architecture. If null is provided, the system default value will be used to generate the client hint.

Parameters:

architecture: The architecture is used to generate user-agent client hint sec-ch-ua-arch.

public UserAgentMetadata.Builder setModel(java.lang.String model)

Sets the user-agent metadata model. If null is provided, the system default value will be used to generate the client hint.

Parameters:

model: The model is used to generate user-agent client hint sec-ch-ua-model.

public UserAgentMetadata.Builder setMobile(boolean mobile)

Sets the user-agent metadata mobile, the default value is true.

Parameters:

mobile: The mobile is used to generate user-agent client hint sec-ch-ua-mobile.

public UserAgentMetadata.Builder setBitness(int bitness)

Sets the user-agent metadata bitness, the default value is UserAgentMetadata.BITNESS_DEFAULT, which indicates an empty string for sec-ch-ua-bitness.

Parameters:

bitness: The bitness is used to generate user-agent client hint sec-ch-ua-bitness.

public UserAgentMetadata.Builder setWow64(boolean wow64)

Sets the user-agent metadata wow64, the default is false.

Parameters:

wow64: The wow64 is used to generate user-agent client hint sec-ch-ua-wow64.