我读了其他帖子,无法弄清楚"诡计".
我查看了Log Collector,但无法使用单独的APK.我基本上使用相同的方法,而且我一直没有得到任何关于流程输入流的信息.
我在清单中有READ_LOGS.
从我的默认活动中,我能够获取日志,但如果我将逻辑移动到另一个活动或使用asynctask,则不返回任何输出.
此代码来自我的默认活动...内联,我将其转储到日志中
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
StringBuilder log=new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
}
Log.d(LOGTAG, "Logcat: " +log.toString());
} catch (IOException e) {}
Run Code Online (Sandbox Code Playgroud)
如果我将它包装在asynctask中或只是在另一个活动中内联它,它什么也不返回
ArrayList<String> commandLine = new ArrayList<String>();
//terminate on completion and suppress everything except the filter
commandLine.add("logcat -d -s");
...
//replace asynctask with inline (could not get log in asynctask)
showProgressDialog(getString(R.string.acquiring_log_progress_dialog_message));
final StringBuilder log = new StringBuilder();
BufferedReader …Run Code Online (Sandbox Code Playgroud)