最近的工作是Android驱动开发,时常需要使用adb shell命令来查询节点下面的很多信息
首先所有的adb shell命令是以ArrayList的格式传入的,查询的结果也是以ArrayList的形式扔出去的
其次C#实际上是调用本地系统应用实现的adb shell命令的执行,所以我们最好的是使用process这个类来实现
最后确保的是adb工具在C:\Windows目录下面
// new process对象
System.Diagnostics.Process p = new System.Diagnostics.Process();
// 设置属性
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
String command = string.Empty;
// 同时执行多条adb shell命令
for (int i = 0; i < commad_array.Count; i++) {
if (i =&