Android抓取系統日誌,並從中得到其他應用的日誌信息

首選,我們得準備一臺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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章