> For the complete documentation index, see [llms.txt](https://developer.gotadi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gotadi.com/english/b2b2c-partner/sdk-method/initiate-sdk/init-android-sdk.md).

# Init Android SDK

### **Import Gotadi SDK into an Android Project** <a href="#import-android-gotadi-sdk-vao-project" id="import-android-gotadi-sdk-vao-project"></a>

#### 1. Download `AndroidGotadiSDK` from SDK link. <a href="#id-1-download-androidgotadisdk-tu-sdk-link" id="id-1-download-androidgotadisdk-tu-sdk-link"></a>

#### 2. **Import the AndroidGotadiSDK Module into an Android Project** <a href="#id-2-import-module-androidgotadisdk-vao-project-android" id="id-2-import-module-androidgotadisdk-vao-project-android"></a>

<div><figure><img src="/files/qVtduIfqq2pmc7tEL7hm" alt=""><figcaption></figcaption></figure> <figure><img src="/files/VQp2ju2i90FhsRt6PydO" alt=""><figcaption></figcaption></figure> <figure><img src="/files/YOfXnzHmZ72sAIMsfODJ" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}

```javascript
After importing, you will see the configuration include ':AndroidGotadiSDK' in the settings.gradle file.
```

{% endhint %}

```gradle
rootProject.name = "My Application"
include ':app'
include ':AndroidGotadiSDK'
```

#### 3. Add AndroidGotadiSDK Dependencies in `build.gradle` to Use the Library. <a href="#id-3-add-dependencies-androidgotadisdk-trong-file-buildgradle-e-su-dung-thu-vien" id="id-3-add-dependencies-androidgotadisdk-trong-file-buildgradle-e-su-dung-thu-vien"></a>

```gradle
dependencies {
    implementation project(path: ':AndroidGotadiSDK')
}
```

#### 4. Add Maven Repositories for AndroidGotadiSDK in build.gradle to Use SDK Libraries. <a href="#id-4-add-maven-repositories-androidgotadisdk-trong-file-buildgradle-e-su-dung-libs-cua-sdk" id="id-4-add-maven-repositories-androidgotadisdk-trong-file-buildgradle-e-su-dung-libs-cua-sdk"></a>

```gradle
allprojects {
    repositories {
        maven {
            url "${project.rootDir}/AndroidGotadiSDK/libs"
        }
        maven {
            url 'https://storage.googleapis.com/download.flutter.io'
        }
    }
}
```

### Example Code khởi tạo AndroidGotadiSDK <a href="#example-code-khoi-tao-androidgotadisdk" id="example-code-khoi-tao-androidgotadisdk"></a>

* Import the SDK Package to Use Functions for Initializing Gotadi Search Book Activity.

```kotlin
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 with `params`:
  * `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`

```kotlin
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")
    }
}
```
