当前位置: 首页>>代码示例>>Java>>正文


Java CrashReportData类代码示例

本文整理汇总了Java中org.acra.collector.CrashReportData的典型用法代码示例。如果您正苦于以下问题:Java CrashReportData类的具体用法?Java CrashReportData怎么用?Java CrashReportData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CrashReportData类属于org.acra.collector包,在下文中一共展示了CrashReportData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {
  String log = createCrashLog(report);
  String url = BASE_URL + ACRA.getConfig().formKey() + CRASHES_PATH;

  try {
    DefaultHttpClient httpClient = new DefaultHttpClient(); 
    HttpPost httpPost = new HttpPost(url);

    List<NameValuePair> parameters = new ArrayList<NameValuePair>(); 
    parameters.add(new BasicNameValuePair("raw", log));
    parameters.add(new BasicNameValuePair("userID", report.get(ReportField.INSTALLATION_ID)));
    parameters.add(new BasicNameValuePair("contact", report.get(ReportField.USER_EMAIL)));
    parameters.add(new BasicNameValuePair("description", report.get(ReportField.USER_COMMENT)));
    
    httpPost.setEntity(new UrlEncodedFormEntity(parameters, HTTP.UTF_8));

    httpClient.execute(httpPost);   
  }
  catch (Exception e) {
    e.printStackTrace();
  } 
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:24,代码来源:HockeySender.java

示例2: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {
  String log = createCrashLog(report);
  String url = BASE_URL + ACRA.getConfig().formKey() + CRASHES_PATH;
 
  try {
    DefaultHttpClient httpClient = new DefaultHttpClient(); 
    HttpPost httpPost = new HttpPost(url);
 
    List<NameValuePair> parameters = new ArrayList<NameValuePair>(); 
    parameters.add(new BasicNameValuePair("raw", log));
    parameters.add(new BasicNameValuePair("userID", report.get(ReportField.INSTALLATION_ID)));
    parameters.add(new BasicNameValuePair("contact", report.get(ReportField.USER_EMAIL)));
    parameters.add(new BasicNameValuePair("description", report.get(ReportField.USER_COMMENT)));
    
    httpPost.setEntity(new UrlEncodedFormEntity(parameters, HTTP.UTF_8));
 
    httpClient.execute(httpPost);   
  }
  catch (Exception e) {
    e.printStackTrace();
  } 
}
 
开发者ID:carltonwhitehead,项目名称:wifi-auto-forget,代码行数:24,代码来源:HockeySender.java

示例3: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {

	final Map<String, String> finalReport = remap(report);

	try {
		OutputStreamWriter osw = new OutputStreamWriter(crashReport);

		Set<Entry<String, String>> set = finalReport.entrySet();
		Iterator<Entry<String, String>> i = set.iterator();

		while (i.hasNext()) {
			Map.Entry<String, String> me = (Entry<String, String>) i.next();
			osw.write("[" + me.getKey() + "]=" + me.getValue());
		}

		osw.flush();
		osw.close();
	} catch (IOException e) {
		Log.e(TAG, "IO ERROR", e);
	}

}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:24,代码来源:CrashReporterSave.java

示例4: load

import org.acra.collector.CrashReportData; //导入依赖的package包/类
/**
 * Loads properties from the specified {@code InputStream}. The encoding is
 * ISO8859-1.
 *
 * @param fileName  Name of the report file from which to load the CrashData.
 * @return CrashReportData read from the supplied InputStream.
 * @throws java.io.IOException if error occurs during reading from the {@code InputStream}.
 */
public CrashReportData load(String fileName) throws IOException {

    final FileInputStream in = context.openFileInput(fileName);
    if (in == null) {
        throw new IllegalArgumentException("Invalid crash report fileName : " + fileName);
    }

    try {
        final BufferedInputStream bis = new BufferedInputStream(in, ACRAConstants.DEFAULT_BUFFER_SIZE_IN_BYTES);
        bis.mark(Integer.MAX_VALUE);
        final boolean isEbcdic = isEbcdic(bis);
        bis.reset();

        if (!isEbcdic) {
            return load(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
        } else {
            return load(new InputStreamReader(bis)); //$NON-NLS-1$
        }
    } finally {
        in.close();
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:31,代码来源:CrashReportPersister.java

示例5: store

import org.acra.collector.CrashReportData; //导入依赖的package包/类
/**
 * Stores the mappings in this Properties to the specified OutputStream,
 * putting the specified comment at the beginning. The output from this
 * method is suitable for being read by the load() method.
 *
 * @param crashData    CrashReportData to save.
 * @param fileName      Name of the file to which to store the CrashReportData.
 * @throws java.io.IOException if the CrashReportData could not be written to the OutputStream.
 */
public void store(CrashReportData crashData, String fileName) throws IOException {

    final OutputStream out = context.openFileOutput(fileName, Context.MODE_PRIVATE);
    try {
        final StringBuilder buffer = new StringBuilder(200);
        final OutputStreamWriter writer = new OutputStreamWriter(out, "ISO8859_1"); //$NON-NLS-1$

        for (final Map.Entry<ReportField, String> entry : crashData.entrySet()) {
            final String key = entry.getKey().toString();
            dumpString(buffer, key, true);
            buffer.append('=');
            dumpString(buffer, entry.getValue(), false);
            buffer.append(LINE_SEPARATOR);
            writer.write(buffer.toString());
            buffer.setLength(0);
        }
        writer.flush();
    } finally {
        out.close();
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:31,代码来源:CrashReportPersister.java

示例6: sendCrashReport

import org.acra.collector.CrashReportData; //导入依赖的package包/类
/**
 * Sends the report with all configured ReportSenders. If at least one
 * sender completed its job, the report is considered as sent and will not
 * be sent again for failing senders.
 * 
 * @param errorContent
 *            Crash data.
 * @throws ReportSenderException
 *             if unable to send the crash report.
 */
private void sendCrashReport(CrashReportData errorContent) throws ReportSenderException {
    if (!ACRA.isDebuggable() || ACRA.getConfig().sendReportsInDevMode()) {
        boolean sentAtLeastOnce = false;
        for (ReportSender sender : reportSenders) {
            try {
                sender.send(errorContent);
                // If at least one sender worked, don't re-send the report
                // later.
                sentAtLeastOnce = true;
            } catch (ReportSenderException e) {
                if (!sentAtLeastOnce) {
                    throw e; // Don't log here because we aren't dealing
                             // with the Exception here.
                } else {
                    Log.w(LOG_TAG,
                            "ReportSender of class "
                                    + sender.getClass().getName()
                                    + " failed but other senders completed their task. ACRA will not send this report again.");
                }
            }
        }
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:34,代码来源:SendWorker.java

示例7: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {
    Uri formUri = mFormUri == null ? Uri.parse(String.format(ACRA.getConfig().googleFormUrlFormat(), ACRA
            .getConfig().formKey())) : mFormUri;
    final Map<String, String> formParams = remap(report);
    // values observed in the GoogleDocs original html form
    formParams.put("pageNumber", "0");
    formParams.put("backupCache", "");
    formParams.put("submit", "Envoyer");

    try {
        final URL reportUrl = new URL(formUri.toString());
        Log.d(LOG_TAG, "Sending report " + report.get(ReportField.REPORT_ID));
        Log.d(LOG_TAG, "Connect to " + reportUrl);

        final HttpRequest request = new HttpRequest();
        request.setConnectionTimeOut(ACRA.getConfig().connectionTimeout());
        request.setSocketTimeOut(ACRA.getConfig().socketTimeout());
        request.setMaxNrRetries(ACRA.getConfig().maxNumberOfRequestRetries());
        request.send(reportUrl, Method.POST, HttpRequest.getParamsAsFormString(formParams), Type.FORM);

    } catch (IOException e) {
        throw new ReportSenderException("Error while sending report to Google Form.", e);
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:26,代码来源:GoogleFormSender.java

示例8: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
        throws ReportSenderException {
    Intent emailIntent = new Intent("android.intent.action.SENDTO");
    emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
    emailIntent.addFlags(268435456);
    String[] subjectBody = this.buildSubjectBody(context, errorContent);
    emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
    emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
    context.startActivity(emailIntent);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:11,代码来源:CrashReportSender.java

示例9: buildSubjectBody

import org.acra.collector.CrashReportData; //导入依赖的package包/类
private String[] buildSubjectBody(Context context, CrashReportData errorContent) {
    ImmutableSet fields = this.config.getReportFields();
    if (fields.isEmpty()) {
        fields = new ImmutableSet<ReportField>(ACRAConstants.DEFAULT_MAIL_REPORT_FIELDS);
    }

    String subject = context.getPackageName() + " Crash Report";
    StringBuilder builder = new StringBuilder();
    Iterator var4 = fields.iterator();

    while (var4.hasNext()) {
        ReportField field = (ReportField) var4.next();
        builder.append(field.toString()).append('=');
        builder.append(errorContent.get(field));
        builder.append('\n');
        if ("STACK_TRACE".equals(field.toString())) {
            String stackTrace = errorContent.get(field);
            if (stackTrace != null) {
                subject = context.getPackageName() + ": "
                        + stackTrace.substring(0, stackTrace.indexOf('\n'));
                if (subject.length() > 72) {
                    subject = subject.substring(0, 72);
                }
            }
        }
    }

    return new String[]{subject, builder.toString()};
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:30,代码来源:CrashReportSender.java

示例10: createCrashLog

import org.acra.collector.CrashReportData; //导入依赖的package包/类
private String createCrashLog(CrashReportData report) {
  Date now = new Date();
  StringBuilder log = new StringBuilder();
  
  log.append("Package: " + report.get(ReportField.PACKAGE_NAME) + "\n");
  log.append("Version: " + report.get(ReportField.APP_VERSION_CODE) + "\n");
  log.append("Android: " + report.get(ReportField.ANDROID_VERSION) + "\n");
  log.append("Manufacturer: " + android.os.Build.MANUFACTURER + "\n");
  log.append("Log: " + report.get(ReportField.LOGCAT) + "\n");
  log.append("Date: " + now + "\n");
  log.append("\n");
  log.append(report.get(ReportField.STACK_TRACE));

  return log.toString();
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:16,代码来源:HockeySender.java

示例11: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
        throws ReportSenderException {
    Intent emailIntent = new Intent("android.intent.action.SENDTO");
    emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), null));
    emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String[] subjectBody = this.buildSubjectBody(context, errorContent);
    emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
    emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
    context.startActivity(emailIntent);
}
 
开发者ID:vit1-irk,项目名称:idec-mobile,代码行数:11,代码来源:CrashReportSender.java

示例12: buildSubjectBody

import org.acra.collector.CrashReportData; //导入依赖的package包/类
private String[] buildSubjectBody(Context context, CrashReportData errorContent) {
    ImmutableSet fields = this.config.getReportFields();
    if (fields.isEmpty()) {
        fields = new ImmutableSet<>(ACRAConstants.DEFAULT_MAIL_REPORT_FIELDS);
    }

    String subject = context.getPackageName() + " Crash Report";
    StringBuilder builder = new StringBuilder();

    for (Object field1 : fields) {
        ReportField field = (ReportField) field1;
        builder.append(field.toString()).append('=');
        builder.append(errorContent.get(field));
        builder.append('\n');
        if ("STACK_TRACE".equals(field.toString())) {
            String stackTrace = errorContent.get(field).toString();
            if (stackTrace != null) {
                subject = context.getPackageName() + ": "
                        + stackTrace.substring(0, stackTrace.indexOf('\n'));
                if (subject.length() > 72) {
                    subject = subject.substring(0, 72);
                }
            }
        }
    }

    return new String[]{subject, builder.toString()};
}
 
开发者ID:vit1-irk,项目名称:idec-mobile,代码行数:29,代码来源:CrashReportSender.java

示例13: onCreate

import org.acra.collector.CrashReportData; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    if (!BuildConfig.DEBUG) {
        ACRA.init(this);
        ACRA.getErrorReporter().addReportSender(new ReportSender() {
            @Override
            public void send(Context context, CrashReportData errorContent) throws ReportSenderException {
                context.getSharedPreferences("crash", MODE_MULTI_PROCESS).edit()
                        .putBoolean("crashed", true).commit();
            }
        });
        ACRA.getErrorReporter().setEnabled(true);
    }
}
 
开发者ID:Kornkammer,项目名称:foodcoapp,代码行数:16,代码来源:FoodcoApplication.java

示例14: send

import org.acra.collector.CrashReportData; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
        throws ReportSenderException {
    Intent emailIntent = new Intent("android.intent.action.SENDTO");
    emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
    emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String[] subjectBody = this.buildSubjectBody(context, errorContent);
    emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
    emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
    context.startActivity(emailIntent);
}
 
开发者ID:f-droid,项目名称:fdroidclient,代码行数:11,代码来源:CrashReportSender.java

示例15: sendCrash

import org.acra.collector.CrashReportData; //导入依赖的package包/类
private void sendCrash() {
    // Retrieve user comment
    final String comment = userComment != null ? userComment.getText().toString() : "";

    // Store the user email
    final String usrEmail;
    if (prefs != null && userEmail != null) {
        usrEmail = userEmail.getText().toString();
        final Editor prefEditor = prefs.edit();
        prefEditor.putString(ACRA.PREF_USER_EMAIL_ADDRESS, usrEmail);
        prefEditor.commit();
    } else {
        usrEmail = "";
    }

    final CrashReportPersister persister = new CrashReportPersister(getApplicationContext());
    try {
        Log.d(LOG_TAG, "Add user comment to " + mReportFileName);
        final CrashReportData crashData = persister.load(mReportFileName);
        crashData.put(USER_COMMENT, comment);
        crashData.put(USER_EMAIL, usrEmail);
        persister.store(crashData, mReportFileName);
    } catch (IOException e) {
        Log.w(LOG_TAG, "User comment not added: ", e);
    }

    // Start the report sending task
    Log.v(ACRA.LOG_TAG, "About to start SenderWorker from CrashReportDialog");
    ACRA.getErrorReporter().startSendingReports(false, true);

    // Optional Toast to thank the user
    final int toastId = ACRA.getConfig().resDialogOkToast();
    if (toastId != 0) {
        ToastSender.sendToast(getApplicationContext(), toastId, Toast.LENGTH_LONG);
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:37,代码来源:CrashReportDialog.java


注:本文中的org.acra.collector.CrashReportData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。