本文介绍了我怎么可以访问设备logcat的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能从设备访问和读取的logcat文件(在/系统/斌/的logcat),用我的应用程序。我的手机是不是植根。
How can I access and read the logcat file (at "/system/bin/logcat") from the device, using my application. My phone is not rooted.
我需要超级用户权限?
推荐答案
您可以通过这个code从应用程序中读取
you can read through this code from your application
ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("logcat"); //$NON-NLS-1$
commandLine.add("-d"); //$NON-NLS-1$
ArrayList<String> arguments =
((params != null) && (params.length > 0)) ? params[0] : null;
if (null != arguments) {
commandLine.addAll(arguments);
}
Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()), 1024);
bufferedReader.readLine()
店铺的BufferedReader在字符串或字符串生成器来检查你的日志
Store this bufferedReader in an string or string builder to check your logs
是的,你需要在你的清单文件权限:
yes you need permission in your manifest file:
<uses-permission android:name="android.permission.READ_LOGS"/>
这篇关于我怎么可以访问设备logcat的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!