由于小程序在打开时会同步检测和更新版本,小程序在打开过程中可能存在等待的过程;为了降低小程序打开的等待时间,优化用户体验,提供了如下的接口用于预下载小程序包。
预下载单个小程序主包
API 说明:
public static void preDownloadPkg(PreDownloadInfo preDownloadInfo, IDownloadCallback callback)
示例代码:
PreDownloadInfo downloadInfo = new PreDownloadInfo("appId");
TmfMiniSDK.preDownloadPkg(downloadInfo, new IDownloadCallback() {
@Override
public void onFinish(DownloadInfo downloadInfo) {
}
@Override
public void onError(DownloadInfo downloadInfo) {
}
});
预下载多个小程序主包
API 说明:
public static void preDownloadPkg(List<PreDownloadInfo> preDownloadInfos, IDownloadCallback callback)
示例代码:
PreDownloadInfo downloadInfo = new PreDownloadInfo("appId");
PreDownloadInfo downloadInfo2 = new PreDownloadInfo("appId2");
ArrayList<PreDownloadInfo>infos = new ArrayList<>();
infos.add(downloadInfo);
infos.add(downloadInfo2);
TmfMiniSDK.preDownloadPkg(infos, new IDownloadCallback() {
@Override
public void onFinish(DownloadInfo downloadInfo) {
}
@Override
public void onError(DownloadInfo downloadInfo) {
}
});
本页内容是否解决了您的问题?