Skip to content

preDownloadGameBySignature ​

Pre-download a Game (by Game Signature) ​

The preDownloadGameBySignature method lets developers download game resources in advance using an already-obtained Game Signature. Compared with downloading directly by game ID, downloading by signature ensures the resource package is of a specific version within a specific authorization scope, offering higher security and version certainty.


Method Declaration ​

java
/**
 * Pre-download a game by game signature
 *
 * @param signature      Game information signature data
 * @param listener       Download status and progress listener
 * @return SUDOPGameTask Task handle, used to manage the download task
 */
public static SUDOPGameTask preDownloadGameBySignature(
    String signature, 
    SUDOPPreDownloadGameListener listener
);

Parameters ​

Encapsulates the authorization information required for the download:

FieldTypeDescription
signatureStringRequired. A valid signature obtained through the getGameSignature interface.

SUDOPPreDownloadGameListener ​

Receives status feedback during the download:

  • void onSuccess(String gameId): The resource package has been downloaded, verified, and extracted.
  • void onFailure(int retCode, String retMsg): Download failed. Common causes include an expired signature, a network error, or insufficient disk space.

Runtime Behavior ​

  1. Signature parsing: The SDK first parses the metadata in gameSignature to obtain the corresponding game ID and resource version number.
  2. Resource comparison: Checks whether a matching version exists in the local cache directory, enabling incremental updates or skipping already-downloaded content.
  3. Secure download: Establishes an encrypted channel to download the resource package, then uses the hash information in the signature to verify integrity after download.

Example Code ​

java
// Start the pre-download task
SUDOPGameTask task = SUDOP.preDownloadGameBySignature("Signature obtained from getGameSignature", new SUDOPPreDownloadGameListener() {
    @Override
    public void onSuccess(String gameId) {
        // Game resources are ready; record the game ID or update the UI
        Log.i("SUDOP", "Pre-download success for game: " + gameId);
    }

    @Override
    public void onFailure(int retCode, String retMsg) {
        // Handle errors
        Log.e("SUDOP", "Pre-download failed: " + retMsg);
    }
});

Notes ​

  • Validity constraint: gameSignature has an expiration time. If the signature has expired before the download starts, the interface will invoke onFailure.
  • Resource overwriting: If the signature points to a new version, the SDK automatically downloads the new resources and manages cleanup of the old version.
  • Lifecycle management: If the Activity is destroyed or the user cancels the operation, be sure to call task.destroy() to stop background traffic consumption.