root - Trying to reboot programmatically rooted Android device -


i'm trying reboot programmatically galaxy s3.

things i've tried:

    try {         process proc = runtime.getruntime().exec(new string[] { "su", "-c", "reboot" });         proc.waitfor();     } catch (exception ex) {         log.i("rebootactivity", "could not reboot", ex);     }      try {         runtime.getruntime().exec(new string[]{"su","-c","reboot now"});     } catch (ioexception e) {         e.printstacktrace();     }      try      {                    process process = runtime.getruntime().exec("su");         dataoutputstream os = new dataoutputstream(process.getoutputstream());         os.writebytes("reboot now\n");     }      catch (throwable t)     {         t.printstacktrace();     } 

do guys have idea how accomplish this?

thanks.

try 1 normal string looking 《su \n reboot; \n》 instead of array. try answer shell, helps lot debugging.

what permissions of su binary? if wrong, try 《chmod 7777 /system/xbin/su》 after 《mount -o remount,rw /system》

here example code: (to run string command, \n , or ; separated list of linux shell commands)

stringbuffer commandoutput = new stringbuffer();     try {         process process = runtime.getruntime().exec("su\n");         dataoutputstream out = new dataoutputstream(process.getoutputstream());         out.writebytes("export ld_library_path=$ld_library_path:/vendor/lib:/system/lib\n");         out.writebytes(command+"\n");         out.flush();          process.waitfor();         bufferedreader in = new bufferedreader(new inputstreamreader(process.getinputstream()));         int numread;         char[] buffer = new char[1000];         while ((numread = in.read(buffer)) > 0) {             commandoutput.append(buffer, 0, numread);         }         in.close();         process.waitfor();     } catch ...      return commandoutput.tostring(); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -