Reliable Hot Reload on Android

A really complex Android app
class HotReloadReceiver(
context: Context,
intentAction: String = "debug",
private val receiver: (Intent) -> Unit
) : BroadcastReceiver() {

init {
context.registerReceiver(this, IntentFilter(intentAction))
}

override fun onReceive(context: Context, intent: Intent) {
receiver(intent)
}
}
override fun onStart() {
super.onStart()
HotReloadReceiver(this) {
val (r, g, b) = intent.getStringExtra("color")
.split(',')
.map(String::toInt)
val color = Color.argb(255, r, g, b)
rectangleView.background = ColorDrawable(color)
}
}
adb shell am broadcast -a debug --es color 0,0,255
Hot Reload in action!

--

--

Android at Tonal. Lottie and Mavericks. Formerly Airbnb and Android Auto at Google.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store