本文整理汇总了Java中org.acra.sender.ReportSenderException类的典型用法代码示例。如果您正苦于以下问题:Java ReportSenderException类的具体用法?Java ReportSenderException怎么用?Java ReportSenderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportSenderException类属于org.acra.sender包,在下文中一共展示了ReportSenderException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.acra.sender.ReportSenderException; //导入依赖的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.sender.ReportSenderException; //导入依赖的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: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {
final Map<String, String> finalReport = remap(report);
try {
OutputStreamWriter osw = new OutputStreamWriter(crashReport);
Set<Entry<String, String>> set = finalReport.entrySet();
Iterator<Entry<String, String>> i = set.iterator();
while (i.hasNext()) {
Map.Entry<String, String> me = (Entry<String, String>) i.next();
osw.write("[" + me.getKey() + "]=" + me.getValue());
}
osw.flush();
osw.close();
} catch (IOException e) {
Log.e(TAG, "IO ERROR", e);
}
}
示例4: sendCrashReport
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
/**
* Sends the report with all configured ReportSenders. If at least one
* sender completed its job, the report is considered as sent and will not
* be sent again for failing senders.
*
* @param errorContent
* Crash data.
* @throws ReportSenderException
* if unable to send the crash report.
*/
private void sendCrashReport(CrashReportData errorContent) throws ReportSenderException {
if (!ACRA.isDebuggable() || ACRA.getConfig().sendReportsInDevMode()) {
boolean sentAtLeastOnce = false;
for (ReportSender sender : reportSenders) {
try {
sender.send(errorContent);
// If at least one sender worked, don't re-send the report
// later.
sentAtLeastOnce = true;
} catch (ReportSenderException e) {
if (!sentAtLeastOnce) {
throw e; // Don't log here because we aren't dealing
// with the Exception here.
} else {
Log.w(LOG_TAG,
"ReportSender of class "
+ sender.getClass().getName()
+ " failed but other senders completed their task. ACRA will not send this report again.");
}
}
}
}
}
示例5: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
throws ReportSenderException {
Intent emailIntent = new Intent("android.intent.action.SENDTO");
emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
emailIntent.addFlags(268435456);
String[] subjectBody = this.buildSubjectBody(context, errorContent);
emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
context.startActivity(emailIntent);
}
示例6: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
throws ReportSenderException {
Intent emailIntent = new Intent("android.intent.action.SENDTO");
emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), null));
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String[] subjectBody = this.buildSubjectBody(context, errorContent);
emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
context.startActivity(emailIntent);
}
示例7: onCreate
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if (!BuildConfig.DEBUG) {
ACRA.init(this);
ACRA.getErrorReporter().addReportSender(new ReportSender() {
@Override
public void send(Context context, CrashReportData errorContent) throws ReportSenderException {
context.getSharedPreferences("crash", MODE_MULTI_PROCESS).edit()
.putBoolean("crashed", true).commit();
}
});
ACRA.getErrorReporter().setEnabled(true);
}
}
示例8: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
throws ReportSenderException {
Intent emailIntent = new Intent("android.intent.action.SENDTO");
emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String[] subjectBody = this.buildSubjectBody(context, errorContent);
emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
context.startActivity(emailIntent);
}
示例9: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
try {
String rootDirectory = Environment.getExternalStorageDirectory()
.getAbsolutePath();
File f = new File(rootDirectory
+ File.separatorChar
+ "osmdroid"
+ File.separatorChar);
f.mkdirs();
f = new File(rootDirectory
+ File.separatorChar
+ "osmdroid"
+ File.separatorChar
+ "crash.log");
if (f.exists())
f.delete();
f.createNewFile();
PrintWriter pw = new PrintWriter(new FileWriter(f));
pw.println(crashReportData.toString());
pw.close();
} catch (Exception exc) {
exc.printStackTrace();
}
}
示例10: setupACRA
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
private void setupACRA() {
String hax0rPackages[] = { "com.koushikdutta.superuser",
"com.noshufou.android.su",
"com.noshufou.android.su.elite",
"com.miui.uac",
"eu.chainfire.supersu",
"eu.chainfire.supersu.pro",
"de.robv.android.xposed.installer",
"biz.bokhorst.xprivacy",
"biz.bokhorst.xprivacy.pro" };
ACRA.init(this);
ErrorReporter er = ACRA.getErrorReporter();
er.setReportSender(
new HttpSender(org.acra.sender.HttpSender.Method.PUT,
org.acra.sender.HttpSender.Type.JSON,
null) {
@Override
public void send(CrashReportData report) throws ReportSenderException {
report.put(ReportField.APPLICATION_LOG, VPNLog.dumpLast());
super.send(report);
}
});
for (String s : hax0rPackages) {
// FIXME: ACRA does not properly escape key strings
// https://github.com/ACRA/acra/issues/90
er.putCustomData("pkg-" + s.replaceAll("\\.", "-"),
isPackageInstalled(s) ? "true" : "false");
}
}
示例11: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
EmailIntentSender emailSender = new EmailIntentSender(getApplicationContext());
emailSender.send(context, crashReportData);
}
示例12: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(Context context, CrashReportData report) throws ReportSenderException {
try {
final String reportAsString = report.toJSON().toString();
HttpSenderService.sendReport(context, formUri, reportAsString, login, password);
} catch (JSONReportException e) {
throw new ReportSenderException("Error while sending " + ACRA.getConfig().reportType()
+ " report via Http " + ACRA.getConfig().httpMethod().name(), e);
}
}
示例13: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(CrashReportData crashReportData) throws ReportSenderException {
sendMailReport(crashReportData);
}
示例14: sendMailReport
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
private void sendMailReport(CrashReportData errorContent) throws ReportSenderException {
new EmailIntentSender(mContext).send(errorContent);
}
示例15: send
import org.acra.sender.ReportSenderException; //导入依赖的package包/类
@Override
public void send(CrashReportData errorContent) throws ReportSenderException {
Log.i("test", "send, " + errorContent);
}