當前位置: 首頁>>代碼示例>>Java>>正文


Java ReportsCrashes類代碼示例

本文整理匯總了Java中org.acra.annotation.ReportsCrashes的典型用法代碼示例。如果您正苦於以下問題:Java ReportsCrashes類的具體用法?Java ReportsCrashes怎麽用?Java ReportsCrashes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReportsCrashes類屬於org.acra.annotation包,在下文中一共展示了ReportsCrashes類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initAcra

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
void initAcra() {
    ReportsCrashes rc = App.class.getAnnotation(ReportsCrashes.class);
    ACRAConfiguration ac = new ACRAConfiguration(rc);
    if (isUiProcess()) {
        ac.setReportsDir("acra-ui-reports");
    } else if (isServiceProcess()) {
        ac.setReportsDir("acra-service-reports");
    } else if (isProviderProcess()) {
        ac.setReportsDir("acra-provider-reports");
    } else {
        Timber.i("Running on emulator disabling crash reporting");
        return;
    }
    if (!StringUtils.isEmpty(rc.formUri())) {
        ACRA.init(this, ac);
        if (!ENABLE_LOGGING) {
            ACRA.setLog(new HollowLog());
        }
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:21,代碼來源:App.java

示例2: getReportFields

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
private List<ReportField> getReportFields() {
    final ReportsCrashes config = ACRA.getConfig();
    final ReportField[] customReportFields = config.customReportContent();

    final ReportField[] fieldsList;
    if (customReportFields.length != 0) {
        Log.d(LOG_TAG, "Using custom Report Fields");
        fieldsList = customReportFields;
    } else if (config.mailTo() == null || "".equals(config.mailTo())) {
        Log.d(LOG_TAG, "Using default Report Fields");
        fieldsList = ACRAConstants.DEFAULT_REPORT_FIELDS;
    } else {
        Log.d(LOG_TAG, "Using default Mail Report Fields");
        fieldsList = ACRAConstants.DEFAULT_MAIL_REPORT_FIELDS;
    }
    return Arrays.asList(fieldsList);
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:18,代碼來源:CrashReportDataFactory.java

示例3: notifySendReport

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * Send a status bar notification.
 * 
 * The action triggered when the notification is selected is to start the
 * {@link CrashReportDialog} Activity.
 * 
 * @param reportFileName
 *            Name of the report file to send.
 */
private void notifySendReport(String reportFileName) {
    // This notification can't be set to AUTO_CANCEL because after a crash,
    // clicking on it restarts the application and this triggers a check
    // for pending reports which issues the notification back.
    // Notification cancellation is done in the dialog activity displayed
    // on notification click.
    final NotificationManager notificationManager = (NotificationManager) mContext
            .getSystemService(Context.NOTIFICATION_SERVICE);

    final ReportsCrashes conf = ACRA.getConfig();

    // Default notification icon is the warning symbol
    final int icon = conf.resNotifIcon();

    final CharSequence tickerText = mContext.getText(conf.resNotifTickerText());
    final long when = System.currentTimeMillis();
    final Notification notification = new Notification(icon, tickerText, when);

    final CharSequence contentTitle = mContext.getText(conf.resNotifTitle());
    final CharSequence contentText = mContext.getText(conf.resNotifText());

    final Intent notificationIntent = new Intent(mContext, CrashReportDialog.class);
    Log.d(LOG_TAG, "Creating Notification for " + reportFileName);
    notificationIntent.putExtra(ACRAConstants.EXTRA_REPORT_FILE_NAME, reportFileName);
    final PendingIntent contentIntent = PendingIntent.getActivity(mContext, mNotificationCounter++, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(mContext, contentTitle, contentText, contentIntent);

    final Intent deleteIntent = new Intent(mContext, CrashReportDialog.class);
    deleteIntent.putExtra(ACRAConstants.EXTRA_FORCE_CANCEL, true);
    notification.deleteIntent = PendingIntent.getActivity(mContext, -1, deleteIntent, 0);
    
    // Send new notification
    notificationManager.notify(ACRAConstants.NOTIF_CRASH_ID, notification);
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:45,代碼來源:ErrorReporter.java

示例4: checkCrashResources

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
   * Checks that mandatory configuration items have been provided.
   * 
   * @throws ACRAConfigurationException
   *             if required values are missing.
   */
  static void checkCrashResources() throws ACRAConfigurationException {
      ReportsCrashes conf = getConfig();
      switch (conf.mode()) {
      case TOAST:
          if (conf.resToastText() == 0) {
              throw new ACRAConfigurationException(
                      "TOAST mode: you have to define the resToastText parameter in your application @ReportsCrashes() annotation.");
          }
          break;
      case NOTIFICATION:
          if (conf.resNotifTickerText() == 0 || conf.resNotifTitle() == 0 || conf.resNotifText() == 0
                  || conf.resDialogText() == 0) {
              throw new ACRAConfigurationException(
                      "NOTIFICATION mode: you have to define at least the resNotifTickerText, resNotifTitle, resNotifText, resDialogText parameters in your application @ReportsCrashes() annotation.");
          }
          break;
      case DIALOG:
          if (conf.resDialogText() == 0) {
              throw new ACRAConfigurationException(
                      "DIALOG mode: you have to define at least the resDialogText parameters in your application @ReportsCrashes() annotation.");
          }
          break;
default:
	break;
      }
  }
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:33,代碼來源:ACRA.java

示例5: getNewDefaultConfig

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * @return new {@link ACRAConfiguration} instance with values initialized
 *         from the {@link ReportsCrashes} annotation.
 */
public static ACRAConfiguration getNewDefaultConfig(Application app) {
    if(app != null) {
        return new ACRAConfiguration(app.getClass().getAnnotation(ReportsCrashes.class));
    } else {
        return new ACRAConfiguration(null);
    }
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:12,代碼來源:ACRA.java

示例6: setDefaultReportSenders

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * Sets relevant ReportSenders to the ErrorReporter, replacing any
 * previously set ReportSender.
 */
public void setDefaultReportSenders() {
    ReportsCrashes conf = ACRA.getConfig();
    Application mApplication = ACRA.getApplication();
    removeAllReportSenders();

    // Try to send by mail. If a mailTo address is provided, do not add
    // other senders.
    if (!"".equals(conf.mailTo())) {
        Log.w(LOG_TAG, mApplication.getPackageName() + " reports will be sent by email (if accepted by user).");
        setReportSender(new EmailIntentSender(mApplication));
        return;
    }

    final PackageManagerWrapper pm = new PackageManagerWrapper(mApplication);
    if (!pm.hasPermission(permission.INTERNET)) {
        // NB If the PackageManager has died then this will erroneously log
        // the error that the App doesn't have Internet (even though it
        // does).
        // I think that is a small price to pay to ensure that ACRA doesn't
        // crash if the PackageManager has died.
        Log.e(LOG_TAG,
                mApplication.getPackageName()
                        + " should be granted permission "
                        + permission.INTERNET
                        + " if you want your crash reports to be sent. If you don't want to add this permission to your application you can also enable sending reports by email. If this is your will then provide your email address in @ReportsCrashes(mailTo=\"[email protected]\"");
        return;
    }

    // If formUri is set, instantiate a sender for a generic HTTP POST form
    // with default mapping.
    if (conf.formUri() != null && !"".equals(conf.formUri())) {
        setReportSender(new HttpSender(ACRA.getConfig().httpMethod(), ACRA.getConfig().reportType(), null));
        return;
    }

    // The default behavior is to use the formKey for a Google Docs Form. If
    // a formUri was also provided, we keep its sender.
    if (conf.formKey() != null && !"".equals(conf.formKey().trim())) {
        addReportSender(new GoogleFormSender());
    }
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:46,代碼來源:ErrorReporter.java

示例7: init

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * <p>
 * Initialize ACRA for a given Application. The call to this method should
 * be placed as soon as possible in the {@link Application#onCreate()}
 * method.
 * </p>
 * 
 * @param app   Your Application class.
 * @throws IllegalStateException if it is called more than once.
 */
public static void init(Application app) {
    final ReportsCrashes reportsCrashes = app.getClass().getAnnotation(ReportsCrashes.class);
    if (reportsCrashes == null) {
        log.e(LOG_TAG,
                "ACRA#init called but no ReportsCrashes annotation on Application " + app.getPackageName());
        return;
    }
    init(app, new ACRAConfiguration(reportsCrashes));
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:20,代碼來源:ACRA.java

示例8: getACRASharedPreferences

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * Retrieves the {@link SharedPreferences} instance where user adjustable
 * settings for ACRA are stored. Default are the Application default
 * SharedPreferences, but you can provide another SharedPreferences name
 * with {@link ReportsCrashes#sharedPreferencesName()}.
 * 
 * @return The Shared Preferences where ACRA will retrieve its user
 *         adjustable setting.
 */
public static SharedPreferences getACRASharedPreferences() {
    ReportsCrashes conf = getConfig();
    if (!"".equals(conf.sharedPreferencesName())) {
        return mApplication.getSharedPreferences(conf.sharedPreferencesName(), conf.sharedPreferencesMode());
    } else {
        return PreferenceManager.getDefaultSharedPreferences(mApplication);
    }
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:18,代碼來源:ACRA.java

示例9: ACRAConfiguration

import org.acra.annotation.ReportsCrashes; //導入依賴的package包/類
/**
 * 
 * @param defaults
 */
public ACRAConfiguration(ReportsCrashes defaults) {
    mReportsCrashes = defaults;
}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:8,代碼來源:ACRAConfiguration.java


注:本文中的org.acra.annotation.ReportsCrashes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。