vendredi 2 janvier 2015

Run su -c "command" process topic

09:44






I want to use su to launch a command and read its output.
I try this code:


Code:


          String line;
            Process cat=Runtime.getRuntime().exec("su -c \"cat /etc/media_codecs.xml\"");
            BufferedReader catStream= new BufferedReader(new InputStreamReader(cat.getInputStream()));
            BufferedReader catSerr= new BufferedReader(new InputStreamReader(cat.getErrorStream()));
            cat.waitFor();
            while((line=catSerr.readLine())!=null)
            {
                System.out.println(line);
            }
            while((line=catStream.readLine())!=null)
            {
                System.out.println(line);
            }


If I manually insert this command in the adb shell it works but with this code the phone ask me for root permission and If I accept I can read only this string to the stderr:
tmp-mksh: cat /etc/media_codecs.xml: not found
And there is not stdout code.

Why?

Thanks,
regards
A993






Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 commentaires:

Enregistrer un commentaire

 

© 2013 Mobile Probleme. All rights resevered. Designed by Templateism

Back To Top