Tool for debug application. Allows you to update any value dynamically
Based on BroadcastReceiver. Content is sent via adb. For your convenience, a script has already been written to send a broadcast message. You receive the message and extract the data.
- Register BroadcastReceiver using extension function. See extension function list
Code sample below show how to register reciver. It`s easy.
// You must provide Context, because onBroadcastReceiveString method is extension of Context
private fun debugReceivingName(context: Context) : Flow<String> {
val debugFlow = MutableSharedFlow<String>(replay = 0, extraBufferCapacity = 1)
// method will called with default arguments
context.onBroadcastReceiveString { receivedString ->
// react to received data
sharedFlow.tryEmit(receivedString)
}
return debugFlow
// collect and update your state in outside this method
}
- Send broadcast message with our script or adb command directly.
- Using our script:
./sendString DEFAULT_ACTION DEFAULT_PAYLOAD "Hello World!"
Don't use in production! This tool can be applied for debuging and developing android application. All extensions call registerBroadcastReceiver()
, but not call unregisterBroadcastReceiver()
method! Care about your users in production.
Today, you can add dependency of library only localy (clone and setup as local module). See sample
- Add lifecycle for unregistering receiver
- Support multiple devices
- Add ability send broadcast with multiple payloads
- Add ability send json
- Create plugin for IDE
- Simplify script usage