- Home /
Question by
EpsilonQoppa · Jul 16, 2017 at 11:54 PM ·
androidlogcat
(How) Can I get logcat data during runtime without native code?
When I was writing android applications in their native language and I wanted to catch errors, I would do something like this:
public static void CaptureUnhandledExceptions()
{
int pid = android.os.Process.myPid();
try {
String command = String.format("logcat -d -v threadtime *:*");
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder result = new StringBuilder();
String currentLine = null;
while ((currentLine = reader.readLine()) != null) {
if (currentLine != null && currentLine.contains(String.valueOf(pid))) {
result.append(currentLine);
result.append("<br/>");
}
}
ExceptionHandler.get_Instance().logMessage(result.toString());
}
catch (Exception e)
{ Log.d("ERROR:", e.toString()); ExceptionHandler.get_Instance().logMessage(e.toString()); }
}
Is there a way I can do this in the Unity with C#?
Comment