public final class CoreConfigurationBuilder extends Object implements ConfigurationBuilder
AcraCore
(04.02.2019 03:17:10)Constructor and Description |
---|
CoreConfigurationBuilder(Context arg0) |
Modifier and Type | Method and Description |
---|---|
CoreConfiguration |
build()
Builds the configuration
|
<R extends ConfigurationBuilder> |
getPluginConfigurationBuilder(Class<R> c) |
CoreConfigurationBuilder |
setAdditionalDropBoxTags(String... additionalDropBoxTags)
Custom tags to be included in DropBox event collection
|
CoreConfigurationBuilder |
setAdditionalSharedPreferences(String... additionalSharedPreferences)
Add here your
SharedPreferences identifier Strings if you use others than your application's default. |
CoreConfigurationBuilder |
setAlsoReportToAndroidFramework(boolean alsoReportToAndroidFramework)
Set this to true if you prefer displaying the native force close dialog after ACRA is done.
|
CoreConfigurationBuilder |
setApplicationLogFile(String applicationLogFile)
To use in combination with
ReportField.APPLICATION_LOG to set the path/name of your application log file. |
CoreConfigurationBuilder |
setApplicationLogFileDir(Directory applicationLogFileDir)
To use in combination with
ReportField.APPLICATION_LOG to set the root for the path provided in applicationLogFile() |
CoreConfigurationBuilder |
setApplicationLogFileLines(int applicationLogFileLines)
To use in combination with
ReportField.APPLICATION_LOG to set the number of latest lines of your application log file to be collected. |
CoreConfigurationBuilder |
setAttachmentUriProvider(Class<? extends AttachmentUriProvider> attachmentUriProvider)
Allows
attachmentUris() configuration at runtime instead of compile time. |
CoreConfigurationBuilder |
setAttachmentUris(String... attachmentUris)
Allows to attach files to crash reports.
|
CoreConfigurationBuilder |
setBuildConfigClass(Class buildConfigClass)
The default value will be a BuildConfig class residing in the same package as the Application class.
|
CoreConfigurationBuilder |
setDeleteOldUnsentReportsOnApplicationStart(boolean deleteOldUnsentReportsOnApplicationStart)
This property can be used to determine whether old (out of date) reports should be sent or not.
|
CoreConfigurationBuilder |
setDeleteUnapprovedReportsOnApplicationStart(boolean deleteUnapprovedReportsOnApplicationStart)
Controls whether unapproved reports are deleted on application start or not.
|
CoreConfigurationBuilder |
setDropboxCollectionMinutes(int dropboxCollectionMinutes)
DropBox event collection will look back this many minutes
|
CoreConfigurationBuilder |
setEnabled(boolean enabled) |
CoreConfigurationBuilder |
setExcludeMatchingSettingsKeys(String... excludeMatchingSettingsKeys)
Provide here regex patterns to be evaluated on each
Settings.System , Settings.Secure and Settings.Global key to exclude KV pairs from being collected. |
CoreConfigurationBuilder |
setExcludeMatchingSharedPreferencesKeys(String... excludeMatchingSharedPreferencesKeys)
Provide here regex patterns to be evaluated on each
SharedPreferences key to exclude KV pairs from the collected SharedPreferences. |
CoreConfigurationBuilder |
setIncludeDropBoxSystemTags(boolean includeDropBoxSystemTags)
If enabled, DropBox events collection will include system tags:
system_app_anr
system_app_wtf
system_app_crash
system_server_anr
system_server_wtf
system_server_crash
BATTERY_DISCHARGE_INFO
SYSTEM_RECOVERY_LOG
SYSTEM_BOOT
SYSTEM_LAST_KMSG
APANIC_CONSOLE
APANIC_THREADS
SYSTEM_RESTART
SYSTEM_TOMBSTONE
data_app_strictmode
|
CoreConfigurationBuilder |
setLogcatArguments(String... logcatArguments)
Arguments to be passed to the logcat command line.
|
CoreConfigurationBuilder |
setLogcatFilterByPid(boolean logcatFilterByPid)
Set this to true if you want to include only logcat lines related to your Application process.
|
CoreConfigurationBuilder |
setLogcatReadNonBlocking(boolean logcatReadNonBlocking)
Set this to true if you want to read logcat lines in a non blocking way for your thread.
|
CoreConfigurationBuilder |
setParallel(boolean parallel)
Allow parallel collection.
|
CoreConfigurationBuilder |
setPluginLoader(PluginLoader pluginLoader)
Set a custom plugin loader.
|
CoreConfigurationBuilder |
setReportContent(ReportField... reportContent)
Redefines the list of
ReportField s collected and sent in your reports. |
CoreConfigurationBuilder |
setReportField(ReportField field,
boolean enable)
Use this if you want to keep the default configuration of reportContent, but set some fields explicitly.
|
CoreConfigurationBuilder |
setReportFormat(StringFormat reportFormat)
Format in which the report should be sent
|
CoreConfigurationBuilder |
setReportSenderFactoryClasses(Class<? extends ReportSenderFactory>... reportSenderFactoryClasses)
Deprecated.
register with plugin loading instead
|
CoreConfigurationBuilder |
setReportSendFailureToast(String reportSendFailureToast)
Toast shown when report sending fails
|
CoreConfigurationBuilder |
setReportSendSuccessToast(String reportSendSuccessToast)
Toast shown when a report is sent successfully
|
CoreConfigurationBuilder |
setResReportSendFailureToast(int resReportSendFailureToast)
Toast shown when report sending fails
|
CoreConfigurationBuilder |
setResReportSendSuccessToast(int resReportSendSuccessToast)
Toast shown when a report is sent successfully
|
CoreConfigurationBuilder |
setRetryPolicyClass(Class<? extends RetryPolicy> retryPolicyClass)
Implement a custom
RetryPolicy to decide if a failed report should be resent or not. |
CoreConfigurationBuilder |
setSendReportsInDevMode(boolean sendReportsInDevMode)
Set this to false if you want to disable sending reports in development mode.
|
CoreConfigurationBuilder |
setSharedPreferencesName(String sharedPreferencesName)
Name of the SharedPreferences that will host ACRA settings which you can make accessible to your users through a preferences screen:
ACRA.PREF_DISABLE_ACRA or ACRA.PREF_ENABLE_ACRA
ACRA.PREF_ALWAYS_ACCEPT
ACRA.PREF_ENABLE_DEVICE_ID
ACRA.PREF_ENABLE_SYSTEM_LOGS
Default is to use the application default SharedPreferences, as retrieved with PreferenceManager.getDefaultSharedPreferences(android.content.Context) |
CoreConfigurationBuilder |
setStopServicesOnCrash(boolean stopServicesOnCrash)
If you have services which might crash on startup android will try to restart them indefinitely.
|
@NonNull public CoreConfigurationBuilder setEnabled(boolean enabled)
@NonNull public CoreConfigurationBuilder setSharedPreferencesName(@NonNull String sharedPreferencesName)
ACRA.PREF_DISABLE_ACRA
or ACRA.PREF_ENABLE_ACRA
ACRA.PREF_ALWAYS_ACCEPT
ACRA.PREF_ENABLE_DEVICE_ID
ACRA.PREF_ENABLE_SYSTEM_LOGS
PreferenceManager.getDefaultSharedPreferences(android.content.Context)
sharedPreferencesName
- SharedPreferences name.@NonNull public CoreConfigurationBuilder setIncludeDropBoxSystemTags(boolean includeDropBoxSystemTags)
includeDropBoxSystemTags
- if system tags are to be included as part of DropBox events.@NonNull public CoreConfigurationBuilder setAdditionalDropBoxTags(@NonNull String... additionalDropBoxTags)
additionalDropBoxTags
- tags that you want to be fetched when collecting DropBox events.@NonNull public CoreConfigurationBuilder setDropboxCollectionMinutes(int dropboxCollectionMinutes)
dropboxCollectionMinutes
- Number of minutes to look back.@NonNull public CoreConfigurationBuilder setLogcatArguments(@NonNull String... logcatArguments)
Arguments to be passed to the logcat command line. Default is { "-t", "100", "-v", "time" } for:
logcat -t 100 -v time
Do not include -b arguments for buffer selection, include ReportField.EVENTSLOG
and ReportField.RADIOLOG
in reportContent()
to activate alternative logcat buffers reporting.
They will use the same other arguments as those provided here.
logcatArguments
- arguments to supply if retrieving the log as part of the report.@NonNull public CoreConfigurationBuilder setReportContent(@NonNull ReportField... reportContent)
Redefines the list of ReportField
s collected and sent in your reports.
You can also use this property to modify fields order in your reports.
The default list is ACRAConstants.DEFAULT_REPORT_FIELDS
reportContent
- fields to be included in the report.@NonNull public CoreConfigurationBuilder setDeleteUnapprovedReportsOnApplicationStart(boolean deleteUnapprovedReportsOnApplicationStart)
Silent and Toast reports are automatically approved. Dialog and Notification reports require explicit approval by the user before they are sent.
On application restart the user is prompted with approval for one unsent report. So you generally don't want to accumulate unapproved reports, otherwise you will prompt them multiple times.
If this is set to true then all unapproved reports bar one will be deleted on application start. The last report is always retained because that is the report that probably just happened.
deleteUnapprovedReportsOnApplicationStart
- if ACRA should delete unapproved reports on application start.@NonNull public CoreConfigurationBuilder setDeleteOldUnsentReportsOnApplicationStart(boolean deleteOldUnsentReportsOnApplicationStart)
deleteOldUnsentReportsOnApplicationStart
- if ACRA should delete any unsent reports on startup if the application has been updated since the last time the application was started.@NonNull public CoreConfigurationBuilder setAlsoReportToAndroidFramework(boolean alsoReportToAndroidFramework)
alsoReportToAndroidFramework
- if the native force close dialog should be displayed.@NonNull public CoreConfigurationBuilder setAdditionalSharedPreferences(@NonNull String... additionalSharedPreferences)
SharedPreferences
identifier Strings if you use others than your application's default. They will be added to the ReportField.SHARED_PREFERENCES
field.additionalSharedPreferences
- names of additional preferences.@NonNull public CoreConfigurationBuilder setLogcatFilterByPid(boolean logcatFilterByPid)
logcatFilterByPid
- true if you want to filter logcat with your process id.@NonNull public CoreConfigurationBuilder setLogcatReadNonBlocking(boolean logcatReadNonBlocking)
logcatReadNonBlocking
- if reading of logcat lines should not block the current thread.@NonNull public CoreConfigurationBuilder setSendReportsInDevMode(boolean sendReportsInDevMode)
sendReportsInDevMode
- if reports should only be sent from signed packages.@NonNull public CoreConfigurationBuilder setExcludeMatchingSharedPreferencesKeys(@NonNull String... excludeMatchingSharedPreferencesKeys)
SharedPreferences
key to exclude KV pairs from the collected SharedPreferences.
This allows you to exclude sensitive user data like passwords from being collected.excludeMatchingSharedPreferencesKeys
- regex patterns, every matching key is not collected.@NonNull public CoreConfigurationBuilder setExcludeMatchingSettingsKeys(@NonNull String... excludeMatchingSettingsKeys)
Settings.System
, Settings.Secure
and Settings.Global
key to exclude KV pairs from being collected.
This allows you to exclude sensitive data from being collected.excludeMatchingSettingsKeys
- regex patterns, every matching key is not collected.@NonNull public CoreConfigurationBuilder setBuildConfigClass(@NonNull Class buildConfigClass)
buildConfigClass
- BuildConfig class from which to read any BuildConfig attributes.@Deprecated @NonNull public CoreConfigurationBuilder setReportSenderFactoryClasses(@NonNull Class<? extends ReportSenderFactory>... reportSenderFactoryClasses)
reportSenderFactoryClasses
- ReportSenderFactory
s with which to construct the ReportSender
s that will send the crash reports.@NonNull public CoreConfigurationBuilder setApplicationLogFile(@NonNull String applicationLogFile)
ReportField.APPLICATION_LOG
to set the path/name of your application log file.applicationLogFile
- path/name of your application log file.@NonNull public CoreConfigurationBuilder setApplicationLogFileLines(int applicationLogFileLines)
ReportField.APPLICATION_LOG
to set the number of latest lines of your application log file to be collected.
Default value is 100.applicationLogFileLines
- number of lines to collect.@NonNull public CoreConfigurationBuilder setApplicationLogFileDir(@NonNull Directory applicationLogFileDir)
ReportField.APPLICATION_LOG
to set the root for the path provided in applicationLogFile()
applicationLogFileDir
- the directory of the application log file@NonNull public CoreConfigurationBuilder setRetryPolicyClass(@NonNull Class<? extends RetryPolicy> retryPolicyClass)
RetryPolicy
to decide if a failed report should be resent or not.retryPolicyClass
- a class that decides if a report should be resent (usually if one or more senders failed).@NonNull public CoreConfigurationBuilder setStopServicesOnCrash(boolean stopServicesOnCrash)
stopServicesOnCrash
- if all services running in a process should be stopped before it is killed.@NonNull public CoreConfigurationBuilder setAttachmentUris(@NonNull String... attachmentUris)
ACRA contains a file provider under the following Uri:
content://[applicationId].acra/[Directory]/[Path]
where [applicationId]
is your application package name, [Directory]
is one of the enum constants in Directory
in lower case and [Path]
is the relative path to the file in that directory
e.g. content://org.acra.test.acra/files/thisIsATest.txt
attachmentUris
- uris to be attached to crash reports.@NonNull public CoreConfigurationBuilder setAttachmentUriProvider(@NonNull Class<? extends AttachmentUriProvider> attachmentUriProvider)
attachmentUris()
configuration at runtime instead of compile time.attachmentUriProvider
- a class that decides which uris should be attached to reports@NonNull public CoreConfigurationBuilder setReportSendSuccessToast(@Nullable String reportSendSuccessToast)
reportSendSuccessToast
- Resource id for the Toast text triggered when a report was sent successfully.@NonNull public CoreConfigurationBuilder setResReportSendSuccessToast(@StringRes int resReportSendSuccessToast)
resReportSendSuccessToast
- Resource id for the Toast text triggered when a report was sent successfully.@NonNull public CoreConfigurationBuilder setReportSendFailureToast(@Nullable String reportSendFailureToast)
reportSendFailureToast
- Resource id for the Toast text triggered when no report was sent successfully.@NonNull public CoreConfigurationBuilder setResReportSendFailureToast(@StringRes int resReportSendFailureToast)
resReportSendFailureToast
- Resource id for the Toast text triggered when no report was sent successfully.@NonNull public CoreConfigurationBuilder setReportFormat(@NonNull StringFormat reportFormat)
reportFormat
- report format@NonNull public CoreConfigurationBuilder setParallel(boolean parallel)
parallel
- if parallel collection should be active@NonNull public CoreConfigurationBuilder setPluginLoader(PluginLoader pluginLoader)
getPluginConfigurationBuilder(Class)
pluginLoader
- the custom implementation@NonNull public CoreConfigurationBuilder setReportField(ReportField field, boolean enable)
field
- the field to setenable
- if this field should be reported@NonNull public <R extends ConfigurationBuilder> R getPluginConfigurationBuilder(Class<R> c)
@NonNull public CoreConfiguration build() throws ACRAConfigurationException
ConfigurationBuilder
build
in interface ConfigurationBuilder
ACRAConfigurationException
- if the configuration is invalid