컴퓨터에 연결된 Android 장치에서 실행중인 앱의 logcat 파일을 수집하는 작은 C# 응용 프로그램을 작성 중입니다.logcat에서 로깅을 중지하고 adb를 프로그래밍 방식으로 종료하는 방법은 무엇입니까?
나는 쉽게 logcat을 시작하고 특정 텍스트 파일에 원하는 줄을 기록 할 수 있습니다. 하지만 로깅에서 logcat을 중지하려고 시도한 모든 명령이 작동하지 않습니다.
관리자 권한으로 내 앱을 실행할 때도 솔루션을 사용해 보았습니다.
static void Main(string[] args)
{
string choice;
string clearLogging = @"adb logcat -c";
string startLogging = @"adb logcat MyApp_LoggingTag:V AndroidRuntime:E *:S > C:\logcat.txt";
string adbDir = @"C:\Users\me\AppData\Local\Android\android-sdk\platform-tools\";
string clearCommand = adbDir + clearLogging;
string startLoggingCommand = adbDir + startLogging;
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", "/K " + clearCommand);
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
//Tried giving the cmd process elevated rights and then use logcat -c - didn't work
//startInfo.Verb = "runas";
Process logcatRunner = Process.Start(startInfo);
//This works!
logcatRunner.StandardInput.WriteLine(startLoggingCommand);
Console.WriteLine("Logging has started.");
Console.Write("Press Enter to stop logging....");
Console.ReadLine();
//-c doesn't work
//logcatRunner.StandardInput.WriteLine(clearCommand);
//Tried killing adb via the logcatRunner process - doesn't work.
//logcatRunner.StandardInput.WriteLine(@"taskkill -f /im ""adb.exe""");
//Tried killing my process - doesn't work - adb is still running and logcat is still writing logs
//logcatRunner.Kill();
Console.WriteLine("Logging has stopped.");
Console.Write(@"Enter any key");
choice = Console.ReadLine();
}
ADB는 아직도 내가 위의 응용 프로그램을 종료 한 후 실행 :
여기 내 코드입니다.
제 질문은 adb를 시작하고 logcat을 성공적으로 시작한 것입니다. 프로그래밍 방식으로 두 프로그램을 모두 닫는 방법은 무엇입니까?
나머지'adb.exe' 과정이 정말 귀찮게하는 경우 - 단지 –