当前位置: 首页>>代码示例>>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;未经允许,请勿转载。