Android with Kotlin integration
Feedback that feels at home on Android.
Jetpack Compose UI, a headless core, device context, offline retries, and feedback history with the same contract as every other platform.
Before you begin
A project, a key, and your app.
Create a project in Heardock and copy its hd_pub_ publishable key. The key identifies the project and is safe to include in your client.
- minSdk 24
- Kotlin 2.0
- Jetpack Compose
Add the source modules
Android currently integrates through source or local modules. Copy or include the core and ui modules, then register them in settings.gradle.kts.
include(":core", ":ui")
// In your app module:
implementation(project(":core"))
implementation(project(":ui"))- The ui module supplies the Compose feedback form, history, and thread screens.
- The core module supplies configuration, transport, context, and the offline queue.
Add the runtime dependencies
The host app provides the Compose and Kotlin runtime dependencies used by the modules.
implementation(platform("androidx.compose:compose-bom:2024.10.01"))
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")Configure in Application
Initialize Heardock once with the application context and your project publishable key.
import com.heardock.core.Heardock
import com.heardock.core.HeardockConfig
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Heardock.shared.configure(
context = this,
config = HeardockConfig(
publicKey = "hd_pub_your_key",
),
)
}
}Show the full-page form
The page presentation is the default. Use onDismiss to close the host activity or navigate back in your existing Compose flow.
setContent {
HeardockFeedbackScreen(
presentation = HeardockPresentation.PAGE,
onDismiss = { finish() },
)
}Use a bottom sheet
Both presentations use the same form and submission logic. The sheet includes its grabber and close button.
ModalBottomSheet(onDismissRequest = { show = false }) {
HeardockFeedbackScreen(
presentation = HeardockPresentation.SHEET,
onDismiss = { show = false },
)
}Theme, localize, and retry offline
Customize the Compose UI or partially override the built-in strings. Failed network submissions enter a local queue; call flushQueue() when the app returns to the foreground.
Heardock.shared.configure(
context = this,
config = HeardockConfig(
publicKey = "hd_pub_your_key",
locale = "zh-CN",
strings = mapOf("title" to "告诉我们你的想法", "send" to "提交"),
),
)
Heardock.shared.updateLocalization(
locale = "fr-FR",
strings = mapOf("title" to "Envoyer un commentaire"),
)Verify the integration
Send one note. Check the whole loop.
- Open the form and select a category.
- Submit a short test message from a debug build.
- Confirm the note and its context appear in your Heardock inbox.
- Reply from the inbox and check the app’s feedback history.
