gpt4 book ai didi

Android 监听/检测日志条目

转载 作者:搜寻专家 更新时间:2023-11-01 09:17:39 27 4
gpt4 key购买 nike

是否可以监听日志条目?即是否存在用于附加日志条目的广播 Intent ?

最佳答案

没有 Intent 。

使用下面的代码:

try
{
Process mLogcatProc = null;
BufferedReader reader = null;
mLogcatProc = Runtime.getRuntime().exec(new String[]{"logcat", "-d"});

reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));

String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");

while ((line = reader.readLine()) != null)
{
log.append(line);
log.append(separator);
}
String w = log.toString();
Toast.makeText(getApplicationContext(),w, Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}

你需要它的许可:

android.permission.READ_LOGS

关于Android 监听/检测日志条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3543846/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com