In an Android app I'm trying to develop the app runs some shell commands at boot running commands through two functions inside a Receiver onReceive() method , but I have two issues:
- The first function executes three separated commands with three calls of
executeCommand(), but since in the code of myexecuteCommand()function is includedProcess.waitFor(), something in the receiver times out and doesn't always execute all the commands. - The second function commands should execute after the three previous shell commands are executed and return a result, and this doesn't happen. If I remove the
Process.waitFor()all the commands are executed, but since the first commands haven't returned a result yet, they act wrong.
Is there a way to extend wait time? Running one only succession of commands instead of three separated commands would reduce the total time of Process.waitFor() ?
IntentServiceto handle the shell commands and execute them in order. See here: developer.android.com/reference/android/content/…, android.content.Intent)