Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for command to finish in RootTools

Tags:

android

root

I am using the RootTools library to execute some shell commands on my android App.

However I need to wait for the commands to finish before proceeding. The documentation shows a waitForFinish() method which is not available on the latest version of the library at least.

How would I accomplish a similar behaviour?

like image 901
Tiago Veloso Avatar asked Nov 11 '22 17:11

Tiago Veloso


1 Answers

This work for me: First you must instace the command without enabling the handler (with false):

Command command = new Command(0, false, "cat")

Next do something like this:

         RootTools.getShell(true).add(command);
         while (!command.isFinished()) 
         {
                try
                {
                    Thread.sleep(50);
                } 
                catch (InterruptedException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

         }
like image 182
Andrea993 Avatar answered Nov 15 '22 06:11

Andrea993