AMSVaultElement.Builder

AMSVaultElement.Builder 是一个构建器类,用于逐步配置并最终创建 AMSVaultElement 实例。通过其构造函数传入必要的参数后,必须调用 build() 方法在主线程中完成实例的构建。

构造

copy
new AMSVaultElement.Builder(Activity activity, AMSBaseConfiguration configuration)

参数

创建 AMSVaultElement.Builder 实例时,需要传入以下参数。

参数

类型

是否必需

描述

activity

Activity

当前 Activity 上下文。

configuration

AMSBaseConfiguration

AMSBaseConfiguration 类的实例,用于提供 SDK 初始化所需的配置。

返回值

返回 AMSVaultElement.Builder 实例,用于继续配置并构建 AMSVaultElement 对象。

build()

在完成 Builder 初始化后,调用 build() 创建 AMSVaultElement 实例。

方法签名

copy
public AMSVaultElement build()

参数

此方法无入参。

返回值

返回已构建的 AMSVaultElement 实例。该实例包含以下主要方法:

注意:若 configurationnull 则返回 null。如果未在主线程调用,则将抛出 RuntimeException

方法名描述
preload()

用于预加载 WebApp 页面和 KYC 页面资源。

createComponent()

用于创建并展示绑卡组件 UI。

reset()

用于重置绑卡流程,清除当前状态。

onDestroy()

用于销毁实例并释放所有关联资源。

示例

copy
AMSBaseConfiguration configuration = new AMSBaseConfiguration();
configuration.setLocale(new Locale("en", "US"));
configuration.setOption("sandbox", true);

AMSVaultElement vaultElement = new AMSVaultElement.Builder(activity, configuration).build();