Skip to content

Instantly share code, notes, and snippets.

@voituk
Created July 19, 2013 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voituk/6039301 to your computer and use it in GitHub Desktop.
Save voituk/6039301 to your computer and use it in GitHub Desktop.
android.getLogcat.java
public static String getLogcat() {
BufferedReader br = null;
try {
Process process = Runtime.getRuntime().exec( new String[] {
"logcat", "-d" //, "-v", "time", "-s", "*:W"
});
br = new BufferedReader( new InputStreamReader(process.getInputStream()), 8*1024);
String line;
StringBuilder log = new StringBuilder();
while ( (line = br.readLine()) != null) {
log.append(line).append("\n");
}
return log.toString();
} catch ( Exception e) {
return null;
} finally {
close(br);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment