2011-04-14 42 views
1

我的目标是清除RAM..For TAT我的想法是重新启动phone..I得到这个代码做针锋相对..重启Android手机通过代码

public static void rebootSU() 
    { 
     Runtime runtime = Runtime.getRuntime(); 
     Process proc = null; 
     OutputStreamWriter osw = null;  
     StringBuilder sbstdOut = new StringBuilder(); 
     StringBuilder sbstdErr = new StringBuilder(); 
     String command="/system/bin/reboot";  
     try { 
      // Run Script  
      proc = runtime.exec("su"); 
      osw = new OutputStreamWriter(proc.getOutputStream()); 
      osw.write(command); 
      osw.flush();  
      osw.close();  
      } catch (IOException ex) { 
       ex.printStackTrace(); 
       } finally {  
        if (osw != null) {  
         try {  
          osw.close(); 
          } catch (IOException e) { 
           e.printStackTrace(); 
           }  
          }  
        } 
       try {  
        if (proc != null)  
         proc.waitFor(); 
        } catch (InterruptedException e) { 
         e.printStackTrace(); 
         } 
        //sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc.getInputStream()))); 
        //sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc.getErrorStream()))); 
        if (proc.exitValue() != 0) 
        {  

        }   
        } 

当我执行这个代码,下面的警告显示在logcat ..我给了REBOOT许可也..当我搜索这个,他们告诉像签署一些固件密钥和所有..但我没有意识到这一点..任何帮助,将不胜感激。

在logcat的

04-14 10:37:13.526: WARN/PackageManager(58): Not granting permission android.permission.REBOOT to package com.RebootTest (protectionLevel=3 flags=0x8446) 
+4

重新启动以清除RAM?听起来像一个不好的最终用户体验.. – Juri 2011-04-14 06:12:35

+0

是一个新手在这..如果它听起来像一个不好的最终用户体验,给我一个清除内存的解决方案。 – prijin 2011-04-14 09:34:02

回答

1

类似的问题被提出和回答here。除非您有固件密钥对其进行签名,否则无法重新启动无根据的电话。

+0

所以任何想法来清除RAM? – prijin 2011-04-14 09:37:34

+0

为什么你甚至想要清除内存? Android平台自己做这件事,它很好 - 为什么会干涉? – alopix 2011-04-14 12:15:57

+0

,以加强安全..通过代码是不可能的,我认为.. ..我的想法是,打电话给用户手动开关关掉他们的电话..然后我重新启动的东西清除......但之后它应该启动我的应用程序..ie,从启动...任何想法关于达???? – prijin 2011-04-16 04:15:10