Android/JVM Integration
Setup
Add dependencies
To integrate the HexDroid release SDK, add the following artifact to your build.gradle.kts
(Kotlin DSL) or
build.gradle
(Groovy):
implementation("com.hexdroid.client.update:core:0.0.1")
Latest version can be found on Maven Central
Install
The entry point to the release library is createUpdateClient
.
You can initialize the client by providing your API key:
val apiKey = "foo_bar"
val updateClient = createUpdateClient(apiKey)
Once initialized, the client is ready to query available releases.
Usage
To check for available releases, use the following code snippet:
import android.os.Build
val target = "${Build.BRAND}/${Build.PRODUCT}/${Build.DEVICE}/${Build.TYPE}/${Build.TAGS}"
updateClient.release(
target = target,
deviceId = getDeviceId(),
currentVersion = getVersion()
).fold(
onSuccess = { release ->
when (release) {
is Release.Available -> Log.i(TAG, "Update available!")
is Release.NoRelease -> Log.i(TAG, "No new updates at this time.")
}
},
onFailure = { error ->
Log.e(TAG, "Error checking for updates: $error", error)
},
)