> For the complete documentation index, see [llms.txt](https://softcom-1.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://softcom-1.gitbook.io/docs/master/android-sdk-1/useage.md).

# Usage

#### Requirements <a href="#requirements" id="requirements"></a>

* The minimum supported SDK version is 21
* Databeaver android SDK 0.2.0 and above only supports projects that have been migrated to [androidx](https://developer.android.com/jetpack/androidx/) For more information, read Google's [migration guide](https://developer.android.com/jetpack/androidx/migrate)

#### Steps

1. Add the code below to the ***root build.gradle*** file&#x20;

```groovy
allprojects {
    repositories {
        ...
        maven {
            url  "https://softcomlimited0.bintray.com/databeaversdk"
            credentials {
                username '<username>'
                password '<password>'
            }
        }
    }
}
```

2\. Add the dependency to the ***module level build.gradle*** file

```groovy
implementation 'ng.softcom.databeaversdk:databeaversdk:<latest-version>'
```

3\. Enable data-binding in your module(and also in other modules that depends on it)

```groovy
buildFeatures {
    dataBinding = true
}
```

4\. Sync and build your project

5\. Create a **DataBeaverSDK** instance and configure it with **DataBeaverSdkSettings** then apply the data and other settings you need

```kotlin
val sdk = DataBeaverSDK(this)
    .configure(DataBeaverSdkSettings().apply {
        
        //FormData -> json string
        setFormData(formData)//(Mandatory)
        
        //Title to be displayed on the appbar/toolbar
        setTitle("Form Title")//(Optional)
        
    })
```

6\. Call the render method on the SDK object

```kotlin
sdk.render()

```

7\. This will render the formData JSON string in a new activity and when done it returns the result back to the activity via onActivityResult

```kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    when(requestCode) {
        SDKConstants.DATA_BEAVER_REQUEST_CODE -> {
            when (resultCode) {
                FormRenderingActivity.RESULT_SUCCESS -> {
                    val resultString = data?.getStringExtra(SDKConstants.FORM_RESULT)
                    
                    Toast.makeText(this, "$resultString", Toast.LENGTH_LONG).show()
                }
                FormRenderingActivity.RESULT_CANCELLED -> {
                    Toast.makeText(this, "RESULT CANCELLED", Toast.LENGTH_LONG).show()
                }
                else -> {
                    val reason = data?.getStringExtra(SDKConstants.FORM_MESSAGE)
                    Toast.makeText(this, reason, Toast.LENGTH_LONG).show()
                }
            }

        }
    }
}
```

8\. The result comes in as a string representation of data beaver result object, this string can be converted back into DataBeaverResult object

```kotlin
val dataBeaverResultString = data?.getStringExtra(SDKConstants.FORM_RESULT)

val dataBeaverResult = Gson().fromJson(dataBeaverResultString, DataBeaverResult::class.java)
```

9\. If your form makes use of google maps ensure you add the google maps API key to your **AndroidManifest.xml** file’s within the \<application> tag

```markup
<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="API-KRY-HERE" />
```

<br>

<br>

<br>
