Skip to content

Initialization(required) ​

  • Call this method in the first Activity's onCreate() method of the game and override some lifecycle methods as shown in the following example.
  • This method performs some initialization of the SDK. Before calling other SDK methods, you must first ensure that the SDK is initialized successfully.

Method 1 ​

java
public static void gamedreamerStart(Context context,GamedreamerStartListener gamedreamStartListener)

Parameters ​

ParameterInstructions
contextContext Object
GamedreamStartListenerInitialized listener

Method 2 ​

java
// Available after 1.7.12 (added whether the SDK needs to read and request permissions) ----- Deprecated. The SDK no longer requests any permissions.
//public static void gamedreamerStart(Context context,boolean isRequestPermission,GamedreamerStartListener gamedreamStartListener)

Parameters ​

ParameterInstructions
contextContext Object
isRequestPermissionBoolean,
true: the SDK needs to read permissions,
false: the SDK does not need to read permissions (usually used when the game handles dynamic permission requests)
GamedreamStartListenerInitialized listener

Callback Description ​

GamedreamStartListener.onSuccess and GamedreamStartListener.onExit callback method description:

  • The onSuccess() method is called when initialization succeeds. You can load game resources at this point. The onExit() method is called when initialization fails, and the game must exit in this method. (When initialization fails, the SDK displays a dialog to notify the player, so the game does not need to show another prompt.)

Example Code ​

java
GDSDK.gamedreamerStart(this, new GamedreamerStartListener() {
			
	@Override
	public void onSuccess() {
		// Initialized successfully
    }	
	@Override
	public void onExit() {
          // Must exit the game
	}
});

// Available after 1.7.12 (added whether the SDK needs to read and request permissions) ----- Deprecated
GDSDK.gamedreamerStart(this, false, new GamedreamerStartListener() {
			
	@Override
	public void onSuccess() {
		// Initialized successfully
    }	
	@Override
	public void onExit() {
          // Must exit the game
	}
});

@Override
protected void onStart() {
	super.onStart();
	GDSDK.onStart(this);
}
@Override
protected void onResume() {
	super.onResume();
	GDSDK.onResume(this);
}
	
@Override
protected void onPause() {
	super.onPause();
	GDSDK.onPause(this);
}
	
@Override
protected void onStop() {
	super.onStop();
	GDSDK.onStop(this);
}
	
@Override
protected void onDestroy() {
	super.onDestroy();
	GDSDK.onDestroy(this);
}