Search code examples
javaandroidandroid-pendingintentruntime.exec

Java Android Runtime.getRuntime().exec()


I'm working on an app where I want to run an android shell command using:

Process process = Runtime.getRuntime().exec("input keyevent 85");

This should start/stop the music player for me, and it works when I'm currently on my app. The way I do it is to set a prepared intent beforehand at a certain time, so I can have the music playing in a few minutes.

However, it doesn't work when I have the app running in the background. The intents do print out my Log.i messages in Logcat, so I'm not sure where the problem lies. Perhaps it is a permission problem?


Solution

  • Turns out, using this method, the APK would have to be signed, the device rooted and the APP be placed in the directory of system apps.