怎么获取root权限,这是个问题。网上说用mk+uid能获得,早之前我只会用cmd去获取,而且还要安装一个superuser前提还要是已经破解过的

代码如下:(求大神赐教mk的方法)

 

Process process = null;
                        DataOutputStream os 
= null;
                        
try {
                            process 
= Runtime.getRuntime().exec("su");
                            os 
= new DataOutputStream(process.getOutputStream());
                            os.writeBytes(
" exit \n");
                            os.writeBytes(
" exit \n");
                            os.flush();
                            process.waitFor();
                        } 
catch (Exception e) {
                        } 
finally {
                            
try {
                                
if (os != null) {
                                    os.close();
                                }
                                process.destroy();
                            } 
catch (Exception e) {
                            }
                        }//先获取应用root
 
Process process = null;
    DataOutputStream os = null;
    try {
     process = Runtime.getRuntime().exec("su");
     os = new DataOutputStream(process.getOutputStream());
     os.writeBytes(" reboot -p \n");//重启代码= = 我在cmd里面su了之后还是不能关机,只能重启。哎。
     os.flush();
     process.waitFor();
    } catch (Exception e) {
    } finally {
     try {
      if (os != null) {
       os.close();
      }
      process.destroy();
     } catch (Exception e) {
     }
    }

求大神赐教真正获取root权限。

 

posted on 2011-08-16 16:15  stay  阅读(3736)  评论(1编辑  收藏  举报