0
class  Process2:Thread(){
    override fun run() {
        var string:String="input keyevent "+25;
        var process: Runtime? =Runtime.getRuntime();
            process?.exec(string)
    }
}

When the app goes to the background ,This code doesn't work in the background, How do I make it work in the background?

Tried many methods. You can even monitor the volume, but you can't monitor the keyEvent 24 and 25. I just want to lie down and read with the Bluetooth remote control. But it can certainly be realized, because there are many Bluetooth remote controls to buy. Of course, it can be realized, but how to do it is still a problem

 var string:String="input keyevent "+24+"\n";
 var process:Process = Runtime.getRuntime().exec("/system/bin/sh");
 DataOutputStream os = new DataOutputStream(processKeyEvent.getOutputStream());
 var os:DataOutputStream= DataOutputStream(process.outputStream)
     os.writeBytes(string);

It's no use

box game
  • 1
  • 1
  • Judging by the information in https://stackoverflow.com/q/37289645/14215102 and https://stackoverflow.com/q/4165599/14215102 this is blocked for security reasons. It can only be made to work on a rooted device. –  Jan 23 '22 at 14:01
  • Also this can be useful: [How can I view and examine the Android log?](https://android.stackexchange.com/q/14430) –  Jan 23 '22 at 14:02
  • java.io.IOException: Cannot run program "/system/xbin/su": error=2, No such file or directory – box game Jan 23 '22 at 14:55

0 Answers0