Мне нужно получить отчет об ошибке и загрузить его с моего устройства Android на сервер. Я могу получить отчет об ошибке, вручную запустив команду adb «adbshell bugreportz». Однако я пытаюсь получить отчет программно. Я пробовал код ниже
Мне нужно получить отчет об ошибке и загрузить его с моего устройства Android на сервер. Я могу получить отчет об ошибке, вручную запустив команду adb «adbshell bugreportz». Однако я пытаюсь получить отчет программно. Я пробовал код ниже [code]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(); } } [/code] У меня этот код не сработал. Пожалуйста, дайте мне знать, как я могу этого добиться, если кто-то исследовал эту часть.