Search in sources :

Example 1 with SenderServiceStarter

use of org.acra.sender.SenderServiceStarter in project acra by ACRA.

the class ReportExecutor method startSendingReports.

/**
     * Starts a Thread to start sending outstanding error reports.
     *
     * @param onlySendSilentReports If true then only send silent reports.
     */
private void startSendingReports(boolean onlySendSilentReports) {
    if (enabled) {
        final SenderServiceStarter starter = new SenderServiceStarter(context, config);
        starter.startService(onlySendSilentReports, true);
    } else {
        ACRA.log.w(LOG_TAG, "Would be sending reports, but ACRA is disabled");
    }
}
Also used : SenderServiceStarter(org.acra.sender.SenderServiceStarter)

Example 2 with SenderServiceStarter

use of org.acra.sender.SenderServiceStarter in project acra by ACRA.

the class BaseCrashReportDialog method sendCrash.

/**
     * Send crash report given user's comment and email address. If none should be empty strings
     *
     * @param comment   Comment (may be null) provided by the user.
     * @param userEmail Email address (may be null) provided by the client.
     */
protected final void sendCrash(@Nullable String comment, @Nullable String userEmail) {
    final CrashReportPersister persister = new CrashReportPersister();
    try {
        if (ACRA.DEV_LOGGING)
            ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile);
        final CrashReportData crashData = persister.load(reportFile);
        crashData.putString(USER_COMMENT, comment == null ? "" : comment);
        crashData.putString(USER_EMAIL, userEmail == null ? "" : userEmail);
        persister.store(crashData, reportFile);
    } catch (IOException e) {
        ACRA.log.w(LOG_TAG, "User comment not added: ", e);
    } catch (JSONException e) {
        ACRA.log.w(LOG_TAG, "User comment not added: ", e);
    }
    // Start the report sending task
    final SenderServiceStarter starter = new SenderServiceStarter(getApplicationContext(), config);
    starter.startService(false, true);
    // Optional Toast to thank the user
    final int toastId = config.resDialogOkToast();
    if (toastId != 0) {
        ToastSender.sendToast(getApplicationContext(), toastId, Toast.LENGTH_LONG);
    }
}
Also used : CrashReportData(org.acra.collector.CrashReportData) SenderServiceStarter(org.acra.sender.SenderServiceStarter) JSONException(org.json.JSONException) CrashReportPersister(org.acra.file.CrashReportPersister) IOException(java.io.IOException)

Example 3 with SenderServiceStarter

use of org.acra.sender.SenderServiceStarter in project acra by ACRA.

the class ApplicationStartupProcessor method sendApprovedReports.

/**
     * If ReportingInteractionMode == Toast and at least one non silent report then show a Toast.
     * All approved reports will be sent.
     */
public void sendApprovedReports() {
    final ReportLocator reportLocator = new ReportLocator(context);
    final File[] reportFiles = reportLocator.getApprovedReports();
    if (reportFiles.length == 0) {
        // There are no approved reports, so bail now.
        return;
    }
    if (config.mode() == ReportingInteractionMode.TOAST && hasNonSilentApprovedReports(reportFiles)) {
        ToastSender.sendToast(context, config.resToastText(), Toast.LENGTH_LONG);
    }
    // Send the approved reports.
    final SenderServiceStarter starter = new SenderServiceStarter(context, config);
    starter.startService(false, false);
}
Also used : SenderServiceStarter(org.acra.sender.SenderServiceStarter) ReportLocator(org.acra.file.ReportLocator) File(java.io.File)

Aggregations

SenderServiceStarter (org.acra.sender.SenderServiceStarter)3 File (java.io.File)1 IOException (java.io.IOException)1 CrashReportData (org.acra.collector.CrashReportData)1 CrashReportPersister (org.acra.file.CrashReportPersister)1 ReportLocator (org.acra.file.ReportLocator)1 JSONException (org.json.JSONException)1