Skip to content

Instantly share code, notes, and snippets.

@yangweigbh
Created July 16, 2020 15:01
Show Gist options
  • Save yangweigbh/43e36e3e84f3bc8d2b8f75a3eb1bc15a to your computer and use it in GitHub Desktop.
Save yangweigbh/43e36e3e84f3bc8d2b8f75a3eb1bc15a to your computer and use it in GitHub Desktop.
for (ApplicationExitInfo exitInfo: unprocessedExitInfos) {
if (exitInfo.getReason() == ApplicationExitInfo.REASON_ANR) {
UUID uuid = UUID.randomUUID();
String fileName = "anr_info_" + uuid.toString() + ".trace";
File outFile = new File(getFilesDir().getAbsolutePath() + "/" + fileName);
try (InputStream inputStream = exitInfo.getTraceInputStream()) {
copyStreamToFile(inputStream, outFile);
} catch (IOException e) {
Log.e(TAG, "copyStreamToFile: ", e);
}
// upload the file to server
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment