My aim is to clear the RAM..For tat my idea is to reboot the phone..I got this code to do tat..
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)
{
}
}
When I executed this code, following warning is shown in the logcat..I gave REBOOT permission also..When I searched about this they are telling like signing with some firmware key and all..But I am not at all aware of that..Any help would be appreciated.
In Logcat
04-14 10:37:13.526: WARN/PackageManager(58): Not granting permission android.permission.REBOOT to package com.RebootTest (protectionLevel=3 flags=0x8446)
A similar question was asked and answered here. You can't reboot an unrooted phone until you have the firmware-key to sign it.
精彩评论