startGameBySignature
Start a Game (by Game Signature)
startGameBySignature is the most recommended launch method in production environments. It starts the game using an encrypted Game Signature obtained from the server, ensuring the legitimacy and security of the game version and the validity of user permissions.
This interface automatically handles resource comparison, silent download (if there is no matching version locally), and environment initialization.
Method Declaration
/**
* Start a game by game signature
*
* @param signature Game signature
* @param listener Launch process listener
* @return SUDOPGameTask Task handle
*/
public static SUDOPGameTask startGameBySignature(String signature, SUDOPStartGameListener listener);
/* Specify the language for the loading view name and icon. */
public static SUDOPGameTask startGameBySignature(
String signature, String language, SUDOPStartGameListener listener);Parameters
| Field | Type | Description |
|---|---|---|
| signature | String | Required. The encrypted signature string obtained through getGameSignature. |
| language | String | Optional, available in the three-argument overload. BCP 47 language tag, such as en, zh-CN, or zh-Hant-TW. Selects the game name and icon on the SDK loading view. null or an empty string uses the loading view's current locale. |
| listener | SUDOPStartGameListener | Launch process listener; callbacks are described below. |
1. SUDOPStartGameListener
void onGamePkgDecrypt(GamePkgDecryptHandle handle, String filePath): Game package decryption callback.void onCreated(SUDRTGameHandle gameHandle, SUDOPGameInfo gameInfo): The game instance has been created. gameHandle is the game instance handle, which can be used to control the game lifecycle or interaction later.void onSuccess(String gameId, SUDRTGameHandle gameHandle): The game started successfully.void onFailure(int retCode, String retMsg): The game failed to start.
2. GamePkgDecryptHandle
void success(String decryptedFilePath, boolean isDeleteFile): Decryption succeeded.decryptedFilePath: the path of the decrypted file.isDeleteFile: whether to delete the file after the game finishes loading.void fail(int retCode, String retMsg): Decryption failed.retCode: error code.retMsg: error message description.
Runtime Behavior
- Security check: The SDK first verifies the validity of the signature and parses out the corresponding
gameIdand version constraints. - Hot update check: Compares against the local cache. If the server has an update, an incremental download is triggered.
- Environment reuse: If
preStartorpreLoadwas called previously and the signature matches, the SDK directly returns the ready view, achieving an instant launch. - Rendering activation: After the
onSuccesscallback, the game begins processing touch events and playing audio.
Loading View Language
The two-argument method remains available. Pass a BCP 47 language tag through the new overload to select the game name and icon shown on the SDK loading view. For apps with language switching, use the current Activity's language tag.
If language is null or empty, the SDK uses the loading view's current locale. Displayed content depends on the translations available for the game; the SDK falls back when an exact match is unavailable.
This parameter applies only to the loading view. Configure the game's own language through getAppBaseInfo.language.
Example Code
String signature = "SERVER_SIDE_ENCRYPTED_SIGNATURE";
String language = "zh-Hant-TW"; // Example; use the current Activity language in your app.
SUDOPGameTask gameTask = SUDOP.startGameBySignature(signature, language, new SUDOPStartGameListener() {
@Override
public void onGameViewCreated(View view) {
// Attach view to the host layout here.
}
@Override
public void onProgress(int progress) {
// Update loading progress (0–100).
}
@Override
public void onGamePkgDecrypt(GamePkgDecryptHandle handle, String filePath) {
}
@Override
public void onCreated(SUDRTGameHandle gameHandle, SUDOPGameInfo gameInfo) {
}
@Override
public void onSuccess(String gameId, SUDRTGameHandle gameHandle) {
// Simply attach this View to your app's own page
View gameView = gameHandle.getGameView();
}
@Override
public void onFailure(int retCode, String retMsg) {
}
});Notes
- Signature expiration: A signature usually has a short validity period. If the user stays on the launch page too long and the signature expires, it must be obtained again.
- Instance uniqueness: Calling this method destroys any other running game instance within the current process, to ensure exclusive resource usage.
- Lifecycle synchronization: Be sure to call
task.destroy()in the Activity'sonDestroy; otherwise the game may keep consuming resources in the background.
Also implement onGameViewCreated(View view) to attach the game view and onProgress(int progress) for progress from 0 to 100. The gameInfo argument of onCreated is the SUDOPGameInfo game information.
