[Android] Util: add a method to return the last lines of the application logcat as a string
Adrien Maglo
git at videolan.org
Thu May 8 11:50:57 CEST 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu May 8 11:44:36 2014 +0200| [b6610cf3d1ab461d398bb5eab3dba02142f149d0] | committer: Adrien Maglo
Util: add a method to return the last lines of the application logcat as a string
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=b6610cf3d1ab461d398bb5eab3dba02142f149d0
---
vlc-android/src/org/videolan/vlc/Util.java | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 9751c7c..139a06f 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -237,6 +237,31 @@ public class Util {
}
/**
+ * Get the last 500 lines of the application logcat.
+ *
+ * @return the log string.
+ * @throws IOException
+ */
+ public static String getLogcat() throws IOException {
+ String[] args = { "logcat", "-v", "time", "-d", "-t", "500" };
+
+ Process process = Runtime.getRuntime().exec(args);
+ InputStreamReader input = new InputStreamReader(
+ process.getInputStream());
+ BufferedReader br = new BufferedReader(input);
+ StringBuilder log = new StringBuilder();
+ String line;
+
+ while ((line = br.readLine()) != null)
+ log.append(line + "\n");
+
+ br.close();
+ input.close();
+
+ return log.toString();
+ }
+
+ /**
* Convert time to a string
* @param millis e.g.time/length from file
* @return formated string (hh:)mm:ss
More information about the Android
mailing list