I'm developing an app that will only be used inside the AVD. My objective is automate some tasks. Sometimes, the "back button" needs to be pressed. I know that I can do it using the adb shell. However, I would like make it from my app code. I've tryed to command below, but I'm getting an "Permission denied" error.
Runtime.getRuntime().exec("adb shell input keyevent 4");
Do you have any idea how I can do it or give the necessary permissions?