preDownloadGame
Pre-download a Game (by Game ID)
preDownloadGame downloads the resource packages required by a game (such as scenes, models, and scripts) from the server in advance, without launching the game. This interface supports progress callbacks and is well suited for background downloads in the game lobby or details page, improving loading speed when the user later enters the game.
Method Declaration
java
/**
* Pre-download a game by game ID
*
* @param gameID gameID
* @param listener Download status and progress listener
* @return SUDOPGameTask Task handle, used to cancel or manage the download task
*/
public static SUDOPGameTask preDownloadGame(
String gameID,
SUDOPPreDownloadGameListener listener
);Parameters
Specifies the pre-download target:
| Field | Type | Description |
|---|---|---|
| gameId | String | Required. The unique identifier of the game whose resources should be pre-downloaded. |
SUDOPPreDownloadGameListener
Receives status feedback during the download:
void onSuccess(String gameId): The resource package has been downloaded, verified, and extracted; resources are ready.void onFailure(int retCode, String retMsg): Download failed. Possible causes include insufficient disk space, a network interruption, or an invalid resource ID.
Runtime Behavior
- Version detection: The SDK automatically detects the difference between the locally cached version and the latest version on the server.
- Concurrent download: Uses chunked, multi-threaded download technology to maximize bandwidth utilization and shorten download time.
- Silent processing: This process only involves file I/O and network transfer; it does not consume GPU resources and will not interfere with the App's current UI rendering.
- Integrity check: After download, it automatically performs signature verification and file MD5 checks to ensure the resource package has not been hijacked or corrupted.
Example Code
java
// Initiate the pre-download task
SUDOPGameTask downloadTask = SUDOP.preDownloadGame("game_101", new SUDOPPreDownloadGameListener() {
@Override
public void onSuccess(String gameId) {
// Resources are ready
Log.i("SUDOP", "Game " + gameId + " pre-downloaded successfully.");
}
@Override
public void onFailure(int retCode, String retMsg) {
// Handle download errors
Log.e("SUDOP", "Download failed: " + retMsg);
}
});Notes
- Storage space: It is recommended to check the available storage space on the device before calling.
- Network environment: On mobile networks, prompt the user via UI, or restrict automatic triggering of this interface to Wi-Fi environments.
