Init Android SDK
Gotadi SDK Integration Guide for Android
Import Gotadi SDK into an Android Project
1. Download AndroidGotadiSDK
from SDK link.
AndroidGotadiSDK
from SDK link.2. Import the AndroidGotadiSDK Module into an Android Project



rootProject.name = "My Application"
include ':app'
include ':AndroidGotadiSDK'
3. Add AndroidGotadiSDK Dependencies in build.gradle
to Use the Library.
build.gradle
to Use the Library.dependencies {
implementation project(path: ':AndroidGotadiSDK')
}
4. Add Maven Repositories for AndroidGotadiSDK in build.gradle to Use SDK Libraries.
allprojects {
repositories {
maven {
url "${project.rootDir}/AndroidGotadiSDK/libs"
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
}
Example Code khởi tạo AndroidGotadiSDK
Import the SDK Package to Use Functions for Initializing Gotadi Search Book Activity.
import com.gotadi.AndroidGotadiSDK.GotadiAdapter
import com.gotadi.AndroidGotadiSDK.GotadiCallback
import com.gotadi.AndroidGotadiSDK.GotadiPartnerSetting
Initialize GotadiSDK for Performance Optimization
Set up the environment before running GotadiActivity.
Init setting
environment
of partner withparams
:env
: deploy environment[uat | prod]
partnername
: Partner Name , example:“vib”
language
: Display languages[”vi” | “en”]
token
: JWT Token obtained after authorization from Gotadi's authentication API.theme
:primary
,secondary
import com.gotadi.AndroidGotadiSDK.AndroidGotadiSDK
import com.gotadi.AndroidGotadiSDK.GotadiCallback
import com.gotadi.AndroidGotadiSDK.GotadiPartnerSetting
class GTDExampleAppActivity : AppCompatActivity() {
private var gotadiSDK: AndroidGotadiSDK? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my_app)
val button = findViewById<Button>(R.id.myappButton)
//Call API and get gotadi Token
gotadiSDK = AndroidGotadiSDK(
this,
setting = GotadiPartnerSetting("uat", "vib", "vi","token","
primary"))
button.setOnClickListener {
val intent = gotadiSDK?.createGotadiIntent()
intent?.let {
startActivity(intent)
}
gotadiSDK?.actionHandler?.bookkingResultCallback = object : GotadiCallback {
override fun onCallPayment(gotadiActivity: Context, bookingNumber: String) {
//Handle payment after checkout here
println("bookkingResultCallback - onCallPayment")
gotadiActivity.startActivity(Intent(gotadiActivity, GTDPartnerPaymentActivity::class.java))
println(bookingNumber)
}
}
}
}
override fun onDestroy() {
super.onDestroy()
//Destroy SDK avoid leak memory
gotadiSDK?.dispose()
println("GTDExampleAppActivity is destroy")
}
}
Last updated