Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.17 KB

sdk_init.en.md

File metadata and controls

45 lines (34 loc) · 1.17 KB

Unity Access to Android SDK Initialization

1、SDK Initialization

Interface Description:

Before accessing the Android SDK, you need to initialize the SDK first, and only after the initialization is completed can you use all the functions of the SDK with the background system. Generally, SDK initialization is done after entering the game.

Method definition: void init()

Example:

//Initialization
public void Init() {
	using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
		using (AndroidJavaObject jo = jc.GetStatic("currentActivity")) {
			jo.Call("init");
		}
	}
}

2、Initialization callbacks

Interface Description:

When the SDK is called to initialize the interface, a callback message is sent to the appropriate method.

Method Definition:void onInitFinish(string message)

Parameter Description:

message is the result of the initialization. success=success; fail=failure

Example:

void onInitFinish(string message) {
	Debug.Log("===onInitFinish : " + message);
	if (message == "success") {
		Debug.Log("Initialization success");
	}
	else {
		Debug.Log("Initialization failure");
	}
}