Technical Documentations
  • 🇻🇳Vietnamese
    • Tổng quan
    • Đối tác B2B2C
      • Phương thức Webview
        • API Login
        • Yêu cầu bảo mật
        • Place Order
        • API Get Booking Detail
        • API Commit
        • API Check commit result
      • Phương thức SDK
        • API Login
        • Yêu cầu bảo mật
        • Initiate SDK
          • Init IOS SDK
          • Init Android SDK
        • Place order
        • API Commit
        • API Get booking detail
        • API Check commit result
      • Phương thức API
        • API Login
        • Yêu cầu bảo mật
        • ✈️Flight
          • Search API
          • Booking API
        • 🏨Hotel
          • Search API
          • Booking API
          • Cancellation API
        • Payment API
        • Booking Management API
    • Đối tác Corporate Agent (CA)
      • Qui trình tích hợp
      • API Chứng thực
      • Yêu cầu bảo mật
    • Đối tác Affiliate
    • ❓Câu hỏi thường gặp
      • Các status trong luồng booking Gotadi
      • Quy định Test
        • ✈️Vé máy bay
        • 🏨Khách sạn
      • Bộ Testcase dành cho đối tác B2B2C
      • Quy trình hỗ trợ từ CS
      • Danh sách Airlines
  • 🇬🇧English
    • Overview
    • B2B2C Partner
      • Webview method
        • API Login
        • Security Requirements
        • Place Order
        • API Get Booking Detail
        • API Commit
        • API Check commit result
      • SDK method
        • API Login
        • Security Requirments
        • Initiate SDK
          • Init IOS SDK
          • Init Android SDK
        • Place order
        • API Commit
        • API Get booking detail
        • API Check commit result
      • API method
        • Integration process
        • Login API
        • ✈️Flight
          • Search API
          • Booking API
        • 🏨Hotel
          • Search API
          • Booking API
          • Cancellation API
        • Payment API
    • Corporate Agent Partner (CA)
      • Integration Process
      • Authentication API
      • Security Requirements
    • Affiliate Partner
    • ❓FAQ section
      • Booking Statuses in Gotadi's Booking Flow
      • Regulations for Testing
        • ✈️Flight
        • 🏨Hotel
      • CS Support Overall Flow
      • Airlines List
Powered by GitBook
On this page
  • Import Android Gotadi SDK vào project
  • Example Code khởi tạo AndroidGotadiSDK
  1. Vietnamese
  2. Đối tác B2B2C
  3. Phương thức SDK
  4. Initiate SDK

Init Android SDK

Hướng dẫn tích hợp Android Gotadi SDK

PreviousInit IOS SDKNextPlace order

Last updated 1 year ago

Import Android Gotadi SDK vào project

1. Download AndroidGotadiSDK từ SDK link.

2. Import Module AndroidGotadiSDK vào project Android

Sau khi import sẽ thấy config `include ':AndroidGotadiSDK'` trong file `settings.gradle`
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 package của SDK để sử dụng các function khởi tạo activity Gotadi Search Book

import com.gotadi.AndroidGotadiSDK.GotadiAdapter
import com.gotadi.AndroidGotadiSDK.GotadiCallback
import com.gotadi.AndroidGotadiSDK.GotadiPartnerSetting
  • Khởi tạo GotadiSDK để tối ưu performance

  • Init environment Setting trước khi run GotadiActivity

  • Init setting environment of partner with params:

    • env : Môi trường deploy [uat | prod]

    • partnername: Partner Name , example: “vib”

    • language: Ngôn ngữ hiển thị [”vi” | “en”]

    • token: JWT Token lấy được sau khi authorize từ API authentication của Gotadi

    • 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")
    }
}
🇻🇳