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

猜你喜欢

转载自blog.csdn.net/qq_24179679/article/details/73333651