首選,我們得準備一臺root之後的設備
其次,shellutil工具類(末尾附上demo中自行解壓)
核心方法
new Thread(new Runnable() {
public void run() {
System.out.println("-----getLog service start----");
try {
ArrayList commandLine = new ArrayList();
String SdPath = Environment.getExternalStorageDirectory().getAbsolutePath();
commandLine.add("rm -r " + SdPath + "/LOG/" + name);
commandLine.add("logcat -d -v time -f " + SdPath + "/LOG/" + name);
CommandResult result = ShellUtils.execCommand(commandLine, true);
System.out.println(result.result + "..." + result.errorMsg + "/" + result.successMsg);
readTxt(name);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}).start();
demo地址:http://download.csdn.net/detail/qq_24179679/9872453