Import Android Gotadi SDK vào project
1. Download AndroidGotadiSDK
từ SDK link.
2. Import Module AndroidGotadiSDK
vào project Android
rootProject.name = "My Application"
include ':app'
include ':AndroidGotadiSDK'
3. Add dependencies AndroidGotadiSDK
trong file build.gradle
để sử dụng thư viện
dependencies {
implementation project(path: ':AndroidGotadiSDK')
}
4. Add maven repositories AndroidGotadiSDK
trong file build.gradle
để sử dụng libs của SDK
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 com.gotadi.AndroidGotadiSDK.GotadiAdapter
import com.gotadi.AndroidGotadiSDK.GotadiCallback
import com.gotadi.AndroidGotadiSDK.GotadiPartnerSetting
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")
}
}