deneyin Aşağıdaki kodu yalnızca uygulamanızın günlükleri almak için.
public final class MyAppLogReader {
private static final String TAG = MyAppLogReader.class.getCanonicalName();
private static final String processId = Integer.toString(android.os.Process
.myPid());
public static StringBuilder getLog() {
StringBuilder builder = new StringBuilder();
try {
String[] command = new String[] { "logcat", "-d", "-v", "threadtime" };
Process process = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(processId)) {
builder.append(line);
//Code here
}
}
} catch (IOException ex) {
Log.e(TAG, "getLog failed", ex);
}
return builder;
}
}
Düzenleme
herzaman kendin logcat gelen satırları ayrıştırmak edebilirsiniz AndroidManifest
dosyası
<uses-permission android:name="android.permission.READ_LOGS" />
izni altına ekleyin ve istemediğiniz herhangi bir etiketi görmezden. –