目录

The ArchivesClient class defines APIs related to archives, for example, APIs for submitting and deleting archives.

Public Method Summary

Return

Method

abstract Task<ArchiveSummary>

addArchive(ArchiveDetails details,  ArchiveSummaryUpdate update, boolean isSupportCache)

Submits an archive.

abstract Task<String>

removeArchive(ArchiveSummary summary)

Deletes an archive.

abstract Task<Integer>

getLimitThumbnailSize()

Obtains the maximum size of an archive cover file allowed by Huawei game server.

abstract Task<Integer>

getLimitDetailsSize()

Obtains the maximum size of an archive file allowed by Huawei game server.

abstract Task<Intent>

getShowArchiveListIntent(String title,   boolean allowAddBtn, boolean allowDeleteBtn, int maxArchive)

Obtains the Intent object for the saved game list screen.

abstract Task<ArchiveSummary>

parseSummary(Bundle extras)

Obtains archive metadata from the Bundle object.

abstract Task<List<ArchiveSummary>>

getArchiveSummaryList(boolean isRealTime)

Obtains all archive data. The data can be obtained from the local cache.

abstract Task<OperationResult>

loadArchiveDetails(ArchiveSummary summary)

Reads archive data.

abstract Task<OperationResult>

loadArchiveDetails(ArchiveSummary summary, int diffStrategy)

Reads archive data using a policy.

abstract Task<OperationResult>

loadArchiveDetails(String archiveId, int diffStrategy)

Reads archive data by file name.

abstract Task<OperationResult>

loadArchiveDetails(String archiveId)

Reads archive data without resolving conflicts.

abstract Task<OperationResult>

updateArchive(String archiveId, ArchiveSummaryUpdate update, ArchiveDetails details)

Resolves a data conflict by passing archive data.

abstract Task<OperationResult>

updateArchive(Archive archive)

Resolves a data conflict by passing an archive object.

abstract Task<Bitmap>

getThumbnail(String archiveId)

Obtains the cover data of a specified archive.

Public Methods

public abstract Task<ArchiveSummary> addArchive(ArchiveDetails details, ArchiveSummaryUpdate update, boolean isSupportCache)

Submits an archive asynchronously. This method only adds an archive.

This method is submitted asynchronously. To be specific, if the device is not connected to the network when the app client calls this method, the HMS SDK caches the data locally. The data is submitted to the Huawei server when network connection is restored and the user logs in again. It is unnecessary for developers to pay attention to the execution result of this method.

Input Parameters

Parameter Name

Parameter Description

detailsArchiveDetails object that contains the content of an archive file.

update

ArchiveSummaryUpdate object that contains the archive metadata changes.

isSupportCache

Indicates whether to locally cache data when the network is abnormal and submit the data after the network is recovered.

  • true: yes

  • false: no

Return Values

Type

Description

Task<ArchiveSummary>

Submitted archive metadata.

An error is returned if the archive metadata is not open or has been submitted.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<String> removeArchive(ArchiveSummary summary)

Deletes an archive, including the archive on Huawei game server and in the local cache. Data on Huawei game server is deleted based on the archive ID, and data in the local cache is deleted based on the archive name.

Input Parameters

Parameter Name

Parameter Description

summary

ArchiveSummary object that contains the archive metadata to be deleted.

Return Values

Type

Description

Task<String>

  • ID of the archive in the case of successful deletion.

  • Error code in the case of deletion failure. For details, see Game API Result Codes.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<Integer> getLimitThumbnailSize()

Obtains the maximum size of an archive cover file allowed by Huawei game server.

Return Values

Type

Description

Task<Integer>

Maximum size of an archive cover file, in bytes.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<Integer> getLimitDetailsSize()

Obtains the maximum size of an archive file allowed by Huawei game server.

Return Values

Type

Description

Task<Integer>

Maximum size of an archive file, in bytes.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<Intent> getShowArchiveListIntent(String title, boolean allowAddBtn, boolean allowDeleteBtn, int maxArchive)

Obtains the Intent object for an app to load the saved game list screen.

Input Parameters

Parameter Name

Parameter Description

title

Archive name displayed on the UI.

allowAddBtn

Indicates whether the button for adding an archive is allowed.

  • true: yes

  • false: no

allowDeleteBtn

Indicates whether the button for deleting an archive is allowed.

  • true: The button is allowed.

  • false: The button is not allowed.

maxArchive

Maximum number of archives that can be displayed. The value -1 indicates all archives.

Return Values

Type

Description

Task<Intent>

Asynchronously returned Intent object for the saved game list screen. An app can call the startActivityForResult method to open the saved game list screen.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<ArchiveSummary> parseSummary(Bundle extras)

Obtains archive metadata from the Bundle object.

Input Parameters

Parameter Name

Parameter Description

extras

Bundle object that contains archive data.

Return Values

Type

Description

Task<ArchiveSummary>

Archive metadata in the asynchronously returned Bundle object.

If the Bundle object is invalid or does not contain correct data, null is returned.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<List<ArchiveSummary>> getArchiveSummaryList(boolean isRealTime)

Obtains all archive metadata of the current player. The data can be obtained from the local cache.

Input Parameters

Parameter Name

Parameter Description

isRealTime

Indicates whether to obtain data from Huawei game server.

  • true: Obtain data from Huawei game server.

  • false: Obtain data from the local cache. Data is kept in the local cache for 5 minutes. If there is no local cache or the cache times out, data will be obtained from the game server.

Return Values

Type

Description

Task<List<ArchiveSummary>>

Returns all archive metadata of the current player asynchronously. 

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> loadArchiveDetails(ArchiveSummary summary)

Reads archive metadata based on the ArchiveSummary object. If a conflict occurs during reading, resolve the conflict first.

Input Parameters

Parameter Name

Parameter Description

summary

ArchiveSummary object for reading archive metadata. The ArchiveSummary object is obtained from the getArchiveSummaryList method in most cases.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, a conflict has occurred during archive reading. In this case, use the updateArchive method to resolve the conflict.

If isDifference() of the OperationResult object returns false, no conflict has occurred. In this case, the returned archive metadata and content can be obtained from Archive.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> loadArchiveDetails(ArchiveSummary summary, int diffStrategy)

Reads archive metadata using a specified conflict resolution policy. If a conflict has occurred, resolve the conflict first.

Input Parameters

Parameter Name

Parameter Description

summary

ArchiveSummary object for reading archive metadata. The ArchiveSummary object is obtained from the getArchiveSummaryList method in most cases.

diffStrategy

Conflict resolution policy.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, a conflict has occurred during archive reading. In this case, use the updateArchive method to resolve the conflict.

If isDifference() of the OperationResult object returns false, no conflict has occurred. In this case, the returned archive metadata and content can be obtained from OperationResult.isDifference.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> loadArchiveDetails(String archiveId, int diffStrategy)

Reads archive metadata based on the archive ID. A conflict resolution policy can be specified.

Input Parameters

Parameter Name

Parameter Description

archiveId

ID of the archive metadata to be read.

diffStrategy

Conflict resolution policy.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, a conflict has occurred during archive reading. In this case, use the updateArchive method to resolve the conflict.

If isDifference() of the OperationResult object returns false, no conflict has occurred. In this case, the returned archive metadata and content can be obtained from OperationResult.isDifference.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> loadArchiveDetails(String archiveId)

Reads archive metadata based on the archive ID. A conflict resolution policy cannot be specified.

Input Parameters

Parameter Name

Parameter Description

archiveId

ID of the archive metadata to be read.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, a conflict has occurred during archive reading. In this case, use the updateArchive method to resolve the conflict.

If isDifference() of the OperationResult object returns false, no conflict has occurred. In this case, the returned archive metadata and content can be obtained from OperationResult.isDifference.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> updateArchive(String archiveId, ArchiveSummaryUpdate update, ArchiveDetails details)

Uses the modified archive metadata and archive file content to resolve a data conflict asynchronously. This method replaces the conflicting archive data with the specified ArchiveSummaryUpdate and ArchiveDetails.

Notice:

This method returns an error if the archive has been submitted or the archive metadata is not read.

Input Parameters

Parameter Name

Parameter Description

archiveId

ID of the archive for which a conflict needs to be resolved.

update

Archive metadata object used to resolve a conflict.

details

Content of an archive file object used to resolve a conflict.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, there is still a conflict.

If isDifference() of the OperationResult object returns false, the conflict has been resolved, and the archive metadata and content that have resolved the conflict can be obtained from OperationResult.isDifference.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<OperationResult> updateArchive(Archive archive)

Resolves a data conflict asynchronously using archive data. This method replaces the conflicting archive data with the specified Archive. 

Notice:

This method returns an error if the archive has been submitted or the archive metadata is not read.

Input Parameters

Parameter Name

Parameter Description

archive

Archive object used to resolve a conflict.

Return Values

Type

Description

Task<OperationResult>

If isDifference() of the OperationResult object returns true, there is still a conflict.

If isDifference() of the OperationResult object returns false, the conflict has been resolved, and the archive metadata and content that have resolved the conflict can be obtained from OperationResult.isDifference.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.

public abstract Task<Bitmap> getThumbnail(String archiveId)

Obtains the bitmap of an archive cover when the cover exists.

Input Parameters

parameterdescription

archiveId

ID of the archive for which the cover needs to be obtained.

Return Values

typedescription

Task<Bitmap>

Obtained cover in bitmap format.