从eclipse LogCat
发送我的应用程序当前事件日志。
我发现我们可以通过定义-
String logcatArguments[] = { "-t", "100", "-v", "long","ActivityManager:I" ,"*:D","*:S"};
但是当我使用ACRA按钮点击发送时,LOGCAT
是空的"。
如何使用ACRA ?
我从-
Sending-reports-for-caught-exceptions-or-for-unexpected-application-state-without-any-exception .
我的实现按钮点击 -
view.findViewById(R.id.logdone).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String logcatArguments[] = { "-t", "100", "-v", "long","ActivityManager:I" ,"*:D","*:S"};
ACRAConfiguration config = ACRA.getConfig();
config.setMailTo("blabla@xyz.com");
config.setResToastText(R.string.crash_dialog_ok_toast);
config.setLogcatArguments(logcatArguments);
try
{
config.setMode(ReportingInteractionMode.TOAST);
}
catch (ACRAConfigurationException e)
{
e.printStackTrace();
}
ACRA.setConfig(config);
ACRA.getErrorReporter().handleException(null);
try {
config.setMode(ReportingInteractionMode.SILENT);
} catch (ACRAConfigurationException e) {
e.printStackTrace();
}
ACRA.setConfig(config);
}
});
我的应用程序类代码 -
@ReportsCrashes(formKey = "",
mailTo = "blabla@xyz.com",
customReportContent = { ReportField.USER_CRASH_DATE, ReportField.USER_COMMENT, ReportField.USER_EMAIL,
ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.BRAND, ReportField.APP_VERSION_CODE,
ReportField.APP_VERSION_NAME, ReportField.STACK_TRACE, ReportField.APPLICATION_LOG,
ReportField.LOGCAT
},
mode = ReportingInteractionMode.DIALOG,
resDialogText = R.string.crash_dialog_text)
@Override
public void onCreate() {
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
我在尝试设置ACRA时遇到了类似的问题。我的问题是我没有在Android Manifest中包含读取日志的权限。
<uses-permission android:name="android.permission.READ_LOGS"></uses-permission>
只是再检查一下。