Skip to content

preStartGame ​

Pre-start a Game (by Game ID) ​

preStartGame is the most powerful optimization in the launch flow. It goes further than preLoad: it not only loads resources and initializes the engine, but also simulates the full game launch lifecycle (except for displaying the view).

Through this interface, the game completes all first-screen logic computation in memory. When the user finally calls startGame, the SDK simply "pastes" the already-rendered screen onto the display, achieving true zero-latency instant launch.


Method Declaration ​

java
/**
 * Pre-start a game by game ID
 *
 * @param gameID   Game ID 
 * @param listener Pre-start status listener
 * @return SUDOPGameTask Task handle, used to manage the pre-started game instance
 */
public static SUDOPGameTask preStartGame(
    String gameID, 
    SUDOPPreStartGameListener listener
);

Parameters ​

FieldTypeDescription
gameIdStringRequired. The unique identifier of the game to pre-start.

SUDOPPreStartGameListener ​

Callback interface that receives the pre-start result:

  • void onSuccess(String gameId, SUDRTGameHandleProvider provider): Pre-start succeeded. At this point the game logic is already running in the background, in a "hot-start" ready state.
  • void onFailure(int retCode, String retMsg): Pre-start failed.

Runtime Behavior ​

  1. Full-chain loading: Includes download, extraction, Runtime initialization, and JS script execution.
  2. Business logic activation: The game executes its onLoad and onStart logic, loading the first-screen map, configuration, and network protocols.
  3. Silent rendering: Renders the first-screen frame in a memory buffer, without occupying the physical screen.
  4. Resource exclusivity: Because the game is already running, it occupies relatively high CPU and memory resources.

Example Code ​

java
SUDOPGameTask preStartTask = SUDOP.preStartGame("game_101", new SUDOPPreStartGameListener() {
    @Override
    public void onSuccess(String gameId, SUDRTGameHandleProvider provider) {
        SUDRTGameHandle handle = provider.getGameHandle();
        // Pre-start succeeded; the game is now running in the background
        Log.i("SUDOP", "Game pre-started and running in background.");
        // It is recommended to save the handle and use handle.getGameView() at launch
    }

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

Notes ​

  • Performance overhead: preStart is the most resource-intensive pre-processing operation. Never pre-start multiple games at the same time, or you can easily trigger a system OOM (out of memory).
  • Audio handling: During pre-start, the SDK mutes audio by default until the game view is formally mounted.
  • Timely destruction: If the user cancels entering the game or leaves the related page, you must call preStartTask.destroy(); otherwise the game process will keep running in the background and consume battery.

The success callback returns SUDRTGameHandleProvider. Call provider.getGameHandle() to obtain the SUDRTGameHandle.