我的目标是清除RAM ..对于我的想法是重新启动手机..我有这个代码做的..
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)