本文整理匯總了Java中org.acra.sender.HttpSender類的典型用法代碼示例。如果您正苦於以下問題:Java HttpSender類的具體用法?Java HttpSender怎麽用?Java HttpSender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpSender類屬於org.acra.sender包,在下文中一共展示了HttpSender類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initACRA
import org.acra.sender.HttpSender; //導入依賴的package包/類
private void initACRA() {
Log.d("initACRA(): Initializing ACRA");
CoreConfigurationBuilder configBuilder = new CoreConfigurationBuilder(this);
// Configure connection
configBuilder.setBuildConfigClass(BuildConfig.class);
configBuilder.setSendReportsInDevMode(BuildConfig.ACRA_SEND_REPORTS_IN_DEV_MODE);
configBuilder.setReportFormat(StringFormat.valueOf(BuildConfig.ACRA_REPORT_TYPE));
configBuilder.setExcludeMatchingSharedPreferencesKeys(new String[]{"api_key"});
configBuilder.setReportContent(getCustomAcraReportFields());
// Configure reported content
HttpSenderConfigurationBuilder httpPluginConfigBuilder = configBuilder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class);
httpPluginConfigBuilder.setUri(BuildConfig.ACRA_FORM_URI);
httpPluginConfigBuilder.setBasicAuthLogin(BuildConfig.ACRA_FORM_URI_BASIC_AUTH_LOGIN);
httpPluginConfigBuilder.setBasicAuthPassword(BuildConfig.ACRA_FORM_URI_BASIC_AUTH_PASSWORD);
httpPluginConfigBuilder.setHttpMethod(HttpSender.Method.valueOf(BuildConfig.ACRA_HTTP_METHOD));
httpPluginConfigBuilder.setEnabled(true);
ACRA.init(this, configBuilder);
}
示例2: onCreate
import org.acra.sender.HttpSender; //導入依賴的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);
}
示例3: onCreate
import org.acra.sender.HttpSender; //導入依賴的package包/類
@Override
public void onCreate() {
ACRA.init(this);
com.andryr.musicplayer.acra.HttpSender sender = new com.andryr.musicplayer.acra.HttpSender();
ACRA.getErrorReporter().setReportSender(sender);
super.onCreate();
PrefUtils.init(this);
ArtworkCache.init(this);
ArtistImageCache.init(this);
AudioEffects.init(this);
}
示例4: setupACRA
import org.acra.sender.HttpSender; //導入依賴的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");
}
}
示例5: onCreate
import org.acra.sender.HttpSender; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
final ACRAConfiguration config;
try {
Properties configProps = new Properties();
InputStream in = getAssets().open("acra.properties");
configProps.load(in);
in.close();
config = new ConfigurationBuilder(this)
.setFormUri(configProps.getProperty("FORM-URI"))
.setReportType(HttpSender.Type.JSON)
.setHttpMethod(HttpSender.Method.PUT)
.setFormUriBasicAuthLogin(configProps.getProperty("USERNAME"))
.setFormUriBasicAuthPassword(configProps.getProperty("PASSWORD"))
.build();
ACRA.init(this, config);
} catch (ACRAConfigurationException | IOException e) {
e.printStackTrace();
}
ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(this).imageDownloader(new BaseImageDownloader(this) {
PreferencesUtility prefs = PreferencesUtility.getInstance(TimberApp.this);
@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
if (prefs.loadArtistImages()) return super.getStreamFromNetwork(imageUri, extra);
throw new IOException();
}
}).build();
ImageLoader.getInstance().init(localImageLoaderConfiguration);
L.writeLogs(false);
L.disableLogging();
L.writeDebugLogs(false);
Nammu.init(this);
if (!ATE.config(this, "light_theme").isConfigured()) {
ATE.config(this, "light_theme")
.activityTheme(R.style.AppThemeLight)
.primaryColorRes(R.color.colorPrimaryLightDefault)
.accentColorRes(R.color.colorAccentLightDefault)
.coloredNavigationBar(false)
.usingMaterialDialogs(true)
.commit();
}
if (!ATE.config(this, "dark_theme").isConfigured()) {
ATE.config(this, "dark_theme")
.activityTheme(R.style.AppThemeDark)
.primaryColorRes(R.color.colorPrimaryDarkDefault)
.accentColorRes(R.color.colorAccentDarkDefault)
.coloredNavigationBar(false)
.usingMaterialDialogs(true)
.commit();
}
if (!ATE.config(this, "light_theme_notoolbar").isConfigured()) {
ATE.config(this, "light_theme_notoolbar")
.activityTheme(R.style.AppThemeLight)
.coloredActionBar(false)
.primaryColorRes(R.color.colorPrimaryLightDefault)
.accentColorRes(R.color.colorAccentLightDefault)
.coloredNavigationBar(false)
.usingMaterialDialogs(true)
.commit();
}
if (!ATE.config(this, "dark_theme_notoolbar").isConfigured()) {
ATE.config(this, "dark_theme_notoolbar")
.activityTheme(R.style.AppThemeDark)
.coloredActionBar(false)
.primaryColorRes(R.color.colorPrimaryDarkDefault)
.accentColorRes(R.color.colorAccentDarkDefault)
.coloredNavigationBar(true)
.usingMaterialDialogs(true)
.commit();
}
}
示例6: setDefaultReportSenders
import org.acra.sender.HttpSender; //導入依賴的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());
}
}