preLoadGameByDirectoryPath
Pre-load a Game (by Local Directory Path)
The preLoadGameByDirectoryPath method lets developers pre-load from an already-extracted game resource directory. This interface reads the raw resource files directly from the local file system, skipping the download and extraction steps, making it the fastest of all pre-load methods.
This method is typically used for developer debugging, built-in resource distribution (pre-placing the game package in the Assets/private directory and extracting it), or scenarios where the business side has already handled resource extraction management.
Method Declaration
/**
* Pre-load a game by game directory
*
* @param directoryPath Local game directory
* @param params Parameter object
* @param listener Pre-load status listener
* @return SUDOPGameTask Task handle, used to manage or destroy the pre-load task
*/
public static SUDOPGameTask preLoadGameByDirectoryPath(String directoryPath, SUDOPGamePackageParams params, SUDOPPreLoadGameListener listener);Parameters
Specifies the location of the local resource directory:
| Field | Type | Description |
|---|---|---|
| directoryPath | String | Required. The absolute path of the game resource folder on the device (this directory should contain core files such as app.json). |
1. SUDOPGamePackageParams
Specifies the concrete resource download details:
| Field | Type | Description |
|---|---|---|
| version | String | Required. Game version |
| fid | String | Game package file fingerprint |
| fidType | FIDType | Game package file fingerprint generation method |
| appGameID | String | Required. The specified gameID |
| appCPID | String | The game developer's CP ID |
| appGroupID | String | The game developer's Group ID |
2. FIDType
Specifies the game package file fingerprint generation method
| Field | Type | Description |
|---|---|---|
| MD5 | enum | MD5 algorithm |
| CRC32 | enum | CRC32 algorithm |
| SHA1 | enum | SHA1 algorithm |
| SHA256 | Strenuming | SHA256 algorithm |
4. SUDOPPreLoadGameListener
Callback interface that receives the pre-load result:
void onSuccess(String gameId, SUDRTGameHandleProvider provider): Pre-load succeeded.gameId: The unique game identifier parsed from the directory configuration file.provider: Callprovider.getGameHandle()to obtain the game instance handle.void onFailure(int retCode, String retMsg): Pre-load failed. Common causes include a nonexistent directory path, a missing core configuration file, insufficient permissions, or out of memory.
Runtime Behavior
- Structure scan: The SDK scans the specified directory to verify that the required entry file (such as
app.json) and resource subdirectories exist. - Environment loading: Directly establishes a file stream mapping, starts the runtime environment, and loads the script core.
- Resource pre-read: Reads and parses the first-screen textures, configuration, and scripts in advance according to the configuration.
- Instance generation: Completes all non-UI-layer initialization logic and returns a
SUDRTGameHandlethat is ready to use immediately.
Example Code
// 1. Prepare the local directory parameter
String directoryPath = getFilesDir().getAbsolutePath() + "/extracted_games/game_101/";
// 2. Perform pre-load
SUDOPGamePackageParams params = new SUDOPGamePackageParams();
params.version = "gamePkgVersion";
params.fid = "2e7ca170f33629c7baf4dc430c541c43";
params.fidType = FIDType.MD5;
params.appGameID = "appGameID";
params.appCPID = "Game Developer id";
params.appGroupID = "Game developer group id";
SUDOPGameTask preLoadTask = SUDOP.preLoadGameByDirectoryPath(directoryPath, params, new SUDOPPreLoadGameListener() {
@Override
public void onSuccess(String gameId, SUDRTGameHandleProvider provider) {
SUDRTGameHandle handle = provider.getGameHandle();
}
@Override
public void onFailure(int retCode, String retMsg) {
}
});
// If the Activity is destroyed, remember to release the task
// preLoadTask.destroy();Notes
- Path validity: The path passed in must be a directory path, and it must end with a slash (
/) or otherwise be one the SDK can correctly recognize. - Permission management: Make sure the App has read access to this directory.
- Resource updates: Because the SDK does not manage resource updates under this path, if the business side replaces files in the directory, it is recommended to destroy the old task and call this interface again to reload.
The success callback returns SUDRTGameHandleProvider. Call provider.getGameHandle() to obtain the SUDRTGameHandle.
