android - Check for root freezes -


i'm creating application, in time check root freezes every single time press "check root" button. ideas?

here "check root" code:

process p;         try {             // perform su root privileges             p = runtime.getruntime().exec("su");             dataoutputstream os = new dataoutputstream(p.getoutputstream());             os.writebytes("remount rw");             os.writebytes("echo root test > /system/rootcheck.txt");             os.writebytes("exit\n");             os.flush();              try {                 p.waitfor();                     if (p.exitvalue() != 255){                         //phone rooted                         toast.maketext(getapplicationcontext(), "your device rooted\r\n\r\n(long press know how root acess)", 0).show();                         break;                     }                     else {                         //phone not rooted                         toast.maketext(getapplicationcontext(), "your device not rooted\r\n\r\n(long press know how root acess)", 0).show();                         break;                     }             } catch (interruptedexception e) {              }         } catch (ioexception e) {          } 

using waitfor() "causes calling thread wait native process associated object finish executing." per sdk specs. looking su command never completes due lack of root access.

perhaps may want use wait(long ms) (documented here) reasonable period of time, , test see if process completed (have root) or timed out (do not have root).


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -