android - 使用 ACRA 时清空崩溃文件

标签 android acra

我正在使用下面的代码生成崩溃文件,该文件是在 parse.com 上创建的,但它是空的。 知道为什么吗?

另一个问题是“ACRA.DEFAULT_REPORT_FIELDS;”有错误,默认报告字段不可用。

public class LocalSender implements ReportSender {  
      private final Map<ReportField, String> mMapping = new HashMap<ReportField, String>() ;  
      private FileOutputStream crashReport = null;  
      private Context ctx;  
      public LocalSender(Context ct) {  
           ctx = ct;  
      }  
      public void send(CrashReportData report) throws ReportSenderException {  
           final Map<String, String> finalReport = remap(report);  
           ByteArrayOutputStream buf = new ByteArrayOutputStream();  
           Log.i("hcsh","Report send");  
           try {  
                Set set = finalReport.entrySet();  
                Iterator i = set.iterator();  
                String tmp;  
                while (i.hasNext()) {  
                     Map.Entry<String,String> me = (Map.Entry) i.next();  
                     tmp = "[" + me.getKey() + "]=" + me.getValue();  
                     buf.write(tmp.getBytes());  
                }  
                ParseFile myFile = new ParseFile("crash.txt", buf.toByteArray());  
                myFile.save();  
                ParseObject jobApplication = new ParseObject("AppCrash");  
                jobApplication.put("MyCrash", "app name");  
                jobApplication.put("applicantResumeFile", myFile);  
                try {  
                     jobApplication.save();  
                } catch (ParseException e) {  
                     // TODO Auto-generated catch block  
                     e.printStackTrace();  
                }  
           }catch (FileNotFoundException e) {  
                Log.e("TAG", "IO ERROR",e);  
           }  
           catch (IOException e) {  
                Log.e("TAG", "IO ERROR",e);  
           } catch (ParseException e) {  
                // TODO Auto-generated catch block  
                e.printStackTrace();  
           }  
 }  
 private Map<String, String> remap(Map<ReportField, String> report) {  
      ReportField[] fields = ACRA.getConfig().customReportContent();  
      if (fields.length == 0) {  
           fields = ACRA.DEFAULT_REPORT_FIELDS;
         }  
      final Map<String, String> finalReport = new HashMap<String, String>(  
                report.size());  
      for (ReportField field : fields) {  
           if (mMapping == null || mMapping.get(field) == null) {  
                finalReport.put(field.toString(), report.get(field));  
           } else {  
                finalReport.put(mMapping.get(field), report.get(field));  
           }  
      }  
      return finalReport;  
 }

 } 

最佳答案

没有ACRA.DEFAULT_REPORT_FIELDS这样的常量。您正在寻找 ACRAConstants.DEFAULT_REPORT_FIELDS

关于android - 使用 ACRA 时清空崩溃文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25328370/

相关文章:

java - 如何以用户友好的方式使用 GoogleDocs 查看 ACRA 异常(exception)情况?

java - 如何根据某些变量更改 RGB 值? (值映射颜色)

android - 在自定义通知中添加按钮操作

java - 通过 ACRA 报告我自己的异常(exception)情况

java - 启动 ACRA 会导致额外的截击问题,可能修复吗?

android - Acra:安装、扩展应用程序 - Activity ?

android - ACRA 的行号不正确

android - PostInvalidateOnAnimation 与 postInvalidate

java - 使用 HttpURLConnection 下载 html 时的奇怪行为

android - ListView 中的 EditText 焦点