本文整理汇总了Java中org.acra.ReportField类的典型用法代码示例。如果您正苦于以下问题:Java ReportField类的具体用法?Java ReportField怎么用?Java ReportField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportField类属于org.acra包,在下文中一共展示了ReportField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.acra.ReportField; //导入依赖的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();
}
}
示例2: send
import org.acra.ReportField; //导入依赖的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();
}
}
示例3: remap
import org.acra.ReportField; //导入依赖的package包/类
private Map<String, String> remap(Map<ReportField, String> report) {
ReportField[] fields = ACRA.getConfig().customReportContent();
if (fields.length == 0) {
fields = ACRAConstants.DEFAULT_REPORT_FIELDS;
}
final Map<String, String> finalReport = new HashMap<String, String>(report.size());
for (ReportField field : fields) {
if (mMapping == null || mMapping.get(field) == null) {
finalReport.put(field.toString(), report.get(field));
} else {
finalReport.put(mMapping.get(field), report.get(field));
}
}
return finalReport;
}
示例4: getReportFields
import org.acra.ReportField; //导入依赖的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);
}
示例5: remap
import org.acra.ReportField; //导入依赖的package包/类
private Map<String, String> remap(Map<ReportField, String> report) {
ReportField[] fields = ACRA.getConfig().customReportContent();
if (fields.length == 0) {
fields = ACRAConstants.DEFAULT_REPORT_FIELDS;
}
final Map<String, String> finalReport = new HashMap<String, String>(report.size());
for (ReportField field : fields) {
if (mMapping == null || mMapping.get(field) == null) {
finalReport.put(field.toString(), report.get(field));
} else {
finalReport.put(mMapping.get(field), report.get(field));
}
}
return finalReport;
}
示例6: send
import org.acra.ReportField; //导入依赖的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);
}
}
示例7: remap
import org.acra.ReportField; //导入依赖的package包/类
private Map<String, String> remap(Map<ReportField, String> report) {
ReportField[] fields = ACRA.getConfig().customReportContent();
if (fields.length == 0) {
fields = ACRAConstants.DEFAULT_REPORT_FIELDS;
}
int inputId = 0;
final Map<String, String> result = new HashMap<String, String>();
for (ReportField originalKey : fields) {
switch (originalKey) {
case APP_VERSION_NAME:
result.put("entry." + inputId + ".single", "'" + report.get(originalKey));
break;
case ANDROID_VERSION:
result.put("entry." + inputId + ".single", "'" + report.get(originalKey));
break;
default:
result.put("entry." + inputId + ".single", report.get(originalKey));
break;
}
inputId++;
}
return result;
}
示例8: onCreate
import org.acra.ReportField; //导入依赖的package包/类
/**
* We do not do any loading or starting when the application is loaded.
* This can be requested by using useService()
*/
@Override
public void onCreate() {
super.onCreate();
LoadStoreIconData.onCreate(this);
ACRAConfiguration config = ACRA.getNewDefaultConfig(this);
config.setFormUri(getString(R.string.acralyzer_http_url));
config.setFormUriBasicAuthLogin(getString(R.string.acralyzer_http_login));
config.setFormUriBasicAuthPassword(getString(R.string.acralyzer_http_pwd));
config.setReportType(HttpSender.Type.JSON);
config.setResToastText(R.string.crash_toast_text);
config.setBuildConfigClass(BuildConfig.class);
try {
config.setMode(ReportingInteractionMode.TOAST);
} catch (ACRAConfigurationException e) {
e.printStackTrace();
}
config.setCustomReportContent(new ReportField[]{ReportField.REPORT_ID, ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.PACKAGE_NAME, ReportField.PHONE_MODEL, ReportField.ANDROID_VERSION, ReportField.BUILD, ReportField.BRAND, ReportField.PRODUCT, ReportField.TOTAL_MEM_SIZE, ReportField.AVAILABLE_MEM_SIZE, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.USER_COMMENT, ReportField.USER_APP_START_DATE, ReportField.USER_CRASH_DATE, ReportField.USER_EMAIL, ReportField.IS_SILENT, ReportField.DEVICE_FEATURES, ReportField.SHARED_PREFERENCES, ReportField.THREAD_DETAILS});
ACRA.setConfig(config);
ACRA.init(this);
lifecycleHandler = new LifecycleHandler();
registerActivityLifecycleCallbacks(lifecycleHandler);
}
示例9: buildSubjectBody
import org.acra.ReportField; //导入依赖的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()};
}
示例10: onCheckedChanged
import org.acra.ReportField; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReportField field = (ReportField) buttonView.getTag();
if (field != null) {
if (isChecked) excludedFields.remove(field);
else excludedFields.add(field);
}
}
示例11: attachBaseContext
import org.acra.ReportField; //导入依赖的package包/类
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
final ACRAConfiguration config;
try {
config = new ConfigurationBuilder(this)
.setCustomReportContent(
ReportField.REPORT_ID,
ReportField.APP_VERSION_CODE,
ReportField.APP_VERSION_NAME,
ReportField.PHONE_MODEL,
ReportField.ANDROID_VERSION,
ReportField.BUILD,
ReportField.BRAND,
ReportField.PRODUCT,
ReportField.TOTAL_MEM_SIZE,
ReportField.AVAILABLE_MEM_SIZE,
ReportField.BUILD_CONFIG,
ReportField.STACK_TRACE,
ReportField.STACK_TRACE_HASH,
ReportField.DISPLAY,
ReportField.USER_COMMENT,
ReportField.USER_APP_START_DATE,
ReportField.USER_CRASH_DATE,
ReportField.DUMPSYS_MEMINFO,
ReportField.INSTALLATION_ID,
ReportField.DEVICE_FEATURES,
ReportField.SETTINGS_SYSTEM,
ReportField.SETTINGS_GLOBAL,
ReportField.THREAD_DETAILS
)
.build();
ACRA.init(this, config);
} catch (ACRAConfigurationException e) {
e.printStackTrace();
}
}
示例12: createCrashLog
import org.acra.ReportField; //导入依赖的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();
}
示例13: buildSubjectBody
import org.acra.ReportField; //导入依赖的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()};
}
示例14: getCustomAcraReportFields
import org.acra.ReportField; //导入依赖的package包/类
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[customizedFields.size()]);
}
示例15: reportError
import org.acra.ReportField; //导入依赖的package包/类
public static void reportError(Throwable error, String comment)
{
if (error == null) {
return;
}
if (comment != null) {
ACRA.getErrorReporter().putCustomData(ReportField.USER_COMMENT.toString(), comment);
}
ACRA.getErrorReporter().handleSilentException(error);
}