preLoadGameBySignature
Pre-load a Game (by Game Signature)
The preLoadGameBySignature method lets developers initialize the game environment in advance using a Game Signature. Compared with using an ID directly, this interface locks a specific game version and authorization context through the signature, ensuring the pre-loaded environment is exactly consistent with the environment at final launch.
This interface not only ensures resources are ready, but also starts the script engine in advance and prepares first-screen rendering.
Method Declaration
/**
* Pre-load a game by game signature
*
* @param signature Game signature
* @param listener Pre-load status listener
* @return SUDOPGameTask Task handle, used to manage or destroy the pre-load task
*/
public static SUDOPGameTask preLoadGameBySignature(
String signature,
SUDOPPreLoadGameListener listener
);Parameters
Encapsulates the authorization information required for pre-load:
| Field | Type | Description |
|---|---|---|
| signature | String | Required. A valid signature obtained through the getGameSignature interface. |
SUDOPPreLoadGameListener
Callback interface that receives the pre-load result:
void onSuccess(String gameId, SUDRTGameHandleProvider provider): Pre-load succeeded.gameId: The parsed game identifier.provider: Callprovider.getGameHandle()to obtain the game instance handle.void onFailure(int retCode, String retMsg): Pre-load failed. Possible causes include an expired signature, a network error, or insufficient system resources.
Runtime Behavior
- Validity verification: The SDK first parses and verifies the validity period and permissions of
gameSignature. - Silent resource preparation: Compares against the local cache; if there is a version update, performs a background silent download.
- Engine warm-up: Loads the corresponding game core and initializes the script execution environment.
- Instance suspension: Creates the
SUDRTGameHandleand completes resource pre-loading, putting the game in a "ready to play" suspended state.
Example Code
// 1. Prepare the pre-load parameters
String signature = "PRE_OBTAINED_GAME_SIGNATURE";
// 2. Perform pre-load
SUDOPGameTask preLoadTask = SUDOP.preLoadGameBySignature(signature, new SUDOPPreLoadGameListener() {
@Override
public void onSuccess(String gameId, SUDRTGameHandleProvider provider) {
SUDRTGameHandle handle = provider.getGameHandle();
// Pre-load succeeded
Log.i("SUDOP", "Pre-load success for game: " + gameId);
// The developer can cache the handle here
}
@Override
public void onFailure(int retCode, String retMsg) {
// Pre-load failed
Log.e("SUDOP", "Pre-load failed: " + retMsg);
}
});
// If the user cancels the operation, release the memory occupied by the pre-load
// preLoadTask.destroy();Notes
- Signature matching: The signature used for pre-load must be consistent with the signature expected when the game is later launched.
- Resource occupation: Pre-load occupies actual memory. On low-end devices, decide whether to perform this operation based on memory pressure.
- Destruction logic: If the user ultimately does not enter the game and destroys the related page, be sure to call
preLoadTask.destroy()to release resources; otherwise a memory leak will occur.
The success callback returns SUDRTGameHandleProvider. Call provider.getGameHandle() to obtain the SUDRTGameHandle.
