In this post I will show you how to capture android log using java code.
Above code capture all log of android device and print in console. Yo can manupulate as per you need.
public static
void captureAndroidDevicesLog() {
try {
Process process =
Runtime.getRuntime().exec("adb logcat");
BufferedReader reader = new
BufferedReader(new InputStreamReader(
process.getInputStream()));
String s;
System.out.println("*********************************************");
System.out.println("Printing android
logs");
System.out.println("*********************************************");
while ((s = reader.readLine()) != null) {
System.out.println(s);
}
System.out.println("*********************************************");
System.out.println("End printing
android logs");
System.out.println("*********************************************");
} catch (IOException e) {
e.printStackTrace();
}
}
Above code capture all log of android device and print in console. Yo can manupulate as per you need.
how to capture only spesific logs ?
ReplyDelete