Skip to content

Instantly share code, notes, and snippets.

@Malinskiy
Created May 4, 2020 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Malinskiy/1512eeb0f8d34e4c2845ad4c076bb130 to your computer and use it in GitHub Desktop.
Save Malinskiy/1512eeb0f8d34e4c2845ad4c076bb130 to your computer and use it in GitHub Desktop.
//Use coroutineScope
runBlocking {
//Verify the ADB server is running
StartAdbInteractor().execute()
//Create AndroidDebugBridgeServer instance
val adb = AndroidDebugBridgeServerFactory().apply {
coroutineContext = Dispatchers.IO
}.build()
//Execute requests using suspendable execute() methods. First list available devices
val devices = adb.execute(request = ListDevicesRequest())
val serial = devices.first().serial
//Execute an actual command specifying serial number of device
val output = adb.execute(ShellCommandRequest("echo hello"), serial = serial)
//output == "hello"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment