I found a great feature of Logcat. It can redirect output to a file using the -f command simple parameter. To use it, you can write a Logcat shell in your aLogcat application. Obviously, I did it :)
To use logcat in android, I wrote this code:
Process proc = null; try { proc = Runtime.getRuntime().exec(new String[] { "logcat", <!parametes_here!> }); mReader = new BufferedReader(new InputStreamReader(proc.getInputStream()), 1024); String line; while ((line = mReader.readLine()) != null) { if (line.length() == 0) { continue; } mHandler.sendMessage(mHandler.obtainMessage(Logcat.MSG_READ_LINE, line)); } } catch (IOException e) { Log.e(TAG, "Cannot start process", e); } finally { if (mReader != null) try { mReader.close(); } catch (IOException e) { Log.e(TAG, "Cannot close stream", e); } }
Dmytro
source share