'Command execution in kotlin

I want to execute this command:

Runtime.getRuntime().exec("adb shell dpm set-device-owner com.example.msgshareapp/.AdminReceiver")

This didn't work, then I tried this:

Runtime.getRuntime().exec("dpm set-device-owner com.example.msgshareapp/.AdminReceiver")

And this does completly nothing, anyway of executing this command?



Solution 1:[1]

val command = arrayOf("adb", "shell", "dpm", "set-device-owner", "com.example.msgshareapp/.AdminReceiver")
Runtime.getRuntime().exec(command)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lukas.j