Код: Выделить всё
public static String executeBugreportz() {
try {
Log.d(
"BugReport"
,
"Bug report triggered"
);
// Execute the adb shell command
Process process = Runtime.getRuntime().exec("adb shell bugreportz");
// Get the input stream to read the output from the executed command
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder output = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\n");
}
// Wait for the command to finish executing
int exitCode = process.waitFor();
// Return the output if the execution was successful
if (exitCode == 0) {
Log.d(
"BugReport"
,
"Bug report generated successfully"
);
return output.toString();
} else {
Log.d(
"BugReport"
,
"Failed to execute adb shell bugreportz"
);
return "Failed to execute adb shell bugreportz";
}
} catch (Exception e) {
e.printStackTrace();
Log.d(
"BugReport"
,
"Exception occurred while executing adb shell bugreportz:" + e.getMessage()
);
return "Exception occurred while executing adb shell bugreportz: " + e.getMessage();
}
}
Подробнее здесь: https://stackoverflow.com/questions/789 ... in-android