createRuntime
Create a Runtime Instance
This method initializes the underlying environment (Runtime) required to run games. Typically, only one runtime instance needs to be created throughout the application process lifecycle. This instance manages the core resources and scheduling logic during game execution.
Method Declaration
java
/**
* Create a runtime instance
*
* @param context Context
* @param options Optional parameters
* @param listener Callback listener
*/
public static void createRuntime(Context context, final Bundle options, SUDRT.RuntimeCreateListener listener);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| options | Bundle | No | Custom runtime configuration parameters (such as render mode, custom resource paths, etc.). Pass null to use the default configuration. |
| listener | SUDRT.RuntimeCreateListener | No | Callback invoked after asynchronous creation completes |
SUDRT.RuntimeCreateListener
void onSuccess(SUDRT runtime): Creation succeeded. The returned runtime can be used to load the core and create game handles.void onFailure(Throwable throwable): Creation failed.
Runtime Behavior
- Singleton nature: Although the method is named
create, a single-process architecture usually maintains only one Runtime instance. - Asynchronous preparation: Because the runtime environment may involve loading native libraries or initializing the GPU environment, the result is reported asynchronously via
listener. - Dependencies: Subsequent operations must be called only after
listener.onSuccess:succeeds.
Example Code
java
SUDOP.createRuntime(context, null, new SUDRT.RuntimeCreateListener() {
@Override
public void onSuccess(SUDRT runtime) {
// The returned runtime can be used for loadCore, createGameHandle, and similar operations
}
@Override
public void onFailure(Throwable error) {
}
});Notes
- Lifecycle: The Runtime instance is usually managed internally by the SDK. The
id<SUDRT>obtained by developers is mainly used to confirm environment readiness or perform low-level debugging. - Repeated creation: If a Runtime already exists, calling this method again typically returns the existing instance or reports an error, depending on the SDK's internal policy.
- Thread constraint: It is recommended to initiate the creation request on the main thread; the callback is usually executed on the main thread as well.
