Chuyển tới nội dung chính

Android SDK Initialization

After installing the SDK, initialize it in your Application class before any other SDK calls. [PLACEHOLDER] VLPlay SDK must be initialized once per app launch. Attempting to call SDK features before initialization will throw a VLPlayNotInitializedException. We recommend initializing in Application.onCreate() to ensure it is ready before any Activity or Service starts.

[PLACEHOLDER] The initialization call is synchronous and lightweight — it reads credentials from memory and sets up internal state. Network connections are only established when you call specific features (e.g., login, purchase).

Basic Initialization

MyApplication.kt
import android.app.Application
import vn.vlplay.sdk.VLPlaySDK
import vn.vlplay.sdk.VLPlayConfig

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()

val config = VLPlayConfig.Builder(
appId = "YOUR_APP_ID",
clientSecret = "YOUR_CLIENT_SECRET"
)
.environment(VLPlayConfig.Environment.PRODUCTION)
.enableLogging(BuildConfig.DEBUG)
.build()

VLPlaySDK.initialize(context = this, config = config)
}
}

Register in AndroidManifest

AndroidManifest.xml
<application
android:name=".MyApplication"
...>
</application>

Verify Initialization

if (VLPlaySDK.isInitialized()) {
Log.d("VLPlay", "SDK version: ${VLPlaySDK.version}")
}