org.acra.ReportField Java Examples

The following examples show how to use org.acra.ReportField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ErrorActivity.java    From Instagram-Profile-Downloader with MIT License 6 votes vote down vote up
public static void reportError(final Context context, final CrashReportData report, final ErrorInfo errorInfo) {
    // get key first (don't ask about this solution)
    ReportField key = null;
    for (ReportField k : report.keySet()) {
        if (k.toString().equals("STACK_TRACE")) {
            key = k;
        }
    }
    String[] el = new String[]{report.get(key).toString()};

    Intent intent = new Intent(context, ErrorActivity.class);
    intent.putExtra(ERROR_INFO, errorInfo);
    intent.putExtra(ERROR_LIST, el);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example #2
Source File: ErrorActivity.java    From video-transcoder with GNU General Public License v3.0 6 votes vote down vote up
public static void reportError(final Context context, final CrashReportData report, final ErrorInfo errorInfo)
{
    // get key first (don't ask about this solution)
    ReportField key = null;
    for (ReportField k : report.keySet())
    {
        if (k.toString().equals("STACK_TRACE"))
        {
            key = k;
        }
    }
    String[] el = new String[]{report.get(key).toString()};

    Intent intent = new Intent(context, ErrorActivity.class);
    intent.putExtra(ERROR_INFO, errorInfo);
    intent.putExtra(ERROR_LIST, el);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example #3
Source File: CrashReportSender.java    From Easy_xkcd with Apache License 2.0 6 votes vote down vote up
private String[] buildSubjectBody(Context context, CrashReportData errorContent) {
    ImmutableSet<ReportField> fields = this.config.getReportFields();
    if (fields.isEmpty()) {
        return new String[]{"No ACRA Report Fields found."};
    }

    String subject = context.getPackageName() + " Crash Report";
    StringBuilder builder = new StringBuilder();
    for (ReportField field : fields) {
        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()};
}
 
Example #4
Source File: CrashReportSender.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
private String[] buildSubjectBody(Context context, CrashReportData errorContent) {
    ImmutableSet<ReportField> fields = this.config.getReportFields();
    if (fields.isEmpty()) {
        return new String[]{"No ACRA Report Fields found."};
    }

    String subject = context.getPackageName() + " Crash Report";
    StringBuilder builder = new StringBuilder();
    for (ReportField field : fields) {
        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()};
}
 
Example #5
Source File: GeopaparazziApplication.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    try {

        ACRAConfiguration config = new ConfigurationBuilder(this) //
                .setMailTo(mailTo)//
                .setCustomReportContent(//
                        ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, //
                        ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, //
                        ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT) //
                .setResToastText(R.string.crash_toast_text)//
                .setLogcatArguments("-t", "400", "-v", "time", "GPLOG:I", "*:S") //
                .setReportingInteractionMode(ReportingInteractionMode.TOAST)//
                .build();


        ACRA.init(this, config);
    } catch (ACRAConfigurationException e) {
        e.printStackTrace();
    }
}
 
Example #6
Source File: MyApplication.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
private ReportField[] getCustomAcraReportFields() {
    List<ReportField> customizedFields = new ArrayList<ReportField>(Arrays.asList(ACRAConstants.DEFAULT_REPORT_FIELDS));
    // remove Device ID to make sure it will not be included in report
    customizedFields.remove(ReportField.DEVICE_ID);
    // remove BuildConfig to avoid leakage of configuration data in report
    customizedFields.remove(ReportField.BUILD_CONFIG);
    return customizedFields.toArray(new ReportField[0]);
}
 
Example #7
Source File: CustomHttpSender.java    From mosmetro-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void send(Context context, CrashReportData report) throws ReportSenderException {
    JSONObject build_config = (JSONObject) report.get(ReportField.BUILD_CONFIG.toString());
    if (build_config == null) return;

    try {
        Object branch = build_config.get("BRANCH_NAME");
        Object build = build_config.get("BUILD_NUMBER");

        if (branch != null && build != null) {
            report.put(ReportField.APP_VERSION_NAME, branch.toString() + " #" + build.toString());
            report.put(ReportField.APP_VERSION_CODE, Integer.parseInt(build.toString()));
        }
    } catch (JSONException|NumberFormatException ignored) {}

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    if (!settings.getBoolean("pref_debug_last_log", true)) {
        report.put(ReportField.APPLICATION_LOG, (String) null);
    } else {
        String log = (String) report.get(ReportField.APPLICATION_LOG.toString());
        if (log != null) {
            int cut = log.lastIndexOf(Logger.CUT);
            if (cut != -1) {
                log = log.substring(cut + Logger.CUT.length() + 1);
                report.put(ReportField.APPLICATION_LOG, log);
            }
        }
    }

    super.send(context, report);
}
 
Example #8
Source File: ApplicationExFilter.java    From tracker-control-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean shouldSendReport(@NonNull Context context, @NonNull CoreConfiguration config, @NonNull CrashReportData crashReportData) {
    return !crashReportData.getString(ReportField.STACK_TRACE).contains("Context.startForegroundService() did not then call Service.startForeground()");
}