i am doing an app for print log cat information in a text view . i use the following code to do that.
Log.e("msg1","message1");
Log.e("msg2","message2");
Log.e("msg3","message3");
try {
String separator = System.getProperty("line.separator");
try {
Process mProcess = Runtime.getRuntime().exec("logcat -e");
BufferedReader reader = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = "";
while ((line = reader.readLine())!= null) {
builder.append(line);
builder.append(separator);
}
System.out.println(separator +"OUTPUT - "+builder.toString());
tv.setText(builder.toString());
} catch (IOException e) { }
and in manifest file i give permission like:
<uses-permission android:name="android.permission.READ_LOGS" />
i could not get no information from locat in the text view. here is the output of the code in the eclipse logcat:
09-18 11:01:51.649: INFO/ActivityManager(66): Displayed activity com.log.cat/.main1: 2224 ms (total 2224 ms)
09-18 11:01:52.799: INFO/ActivityManager(66): Starting activity: Intent { cmp=com.log.cat/.main (has extras) }
09-18 11:01:52.958: ERROR/msg1(346): message1
09-18 11:01:52.958: ERROR/msg2(346): message2
09-18 11:01:52.969: ERROR/msg3(346): message3
09-18 11:01:53.028: INFO/global(346): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
09-18 11:01:53.059: INFO/System.out(346): OUTPUT -
09-18 11:01:53.588: INFO/ActivityManager(66): Displayed activity com.log.cat/.main: 754 ms (total 754 ms)
the system.out. does not print any thing in the logcat. if i use logcat -d instead of logcat -e . it print all system related information in that there is no my logcat information. please help me. i need to show my app logcat information in the textview not other informations so that i use logcat -e. please help me.