public abstract class BaseConfigurationBuilder<T extends BaseConfigurationBuilder>
extends java.lang.Object
ReportsCrashes
(21.03.2018 19:15:27)Constructor and Description |
---|
BaseConfigurationBuilder(android.app.Application app) |
Modifier and Type | Method and Description |
---|---|
T |
setAdditionalDropBoxTags(java.lang.String... additionalDropBoxTags) |
T |
setAdditionalSharedPreferences(java.lang.String... additionalSharedPreferences)
Add here your
SharedPreferences identifier Strings if you use
others than your application's default. |
T |
setAlsoReportToAndroidFramework(boolean alsoReportToAndroidFramework)
Set this to true if you prefer displaying the native force close dialog after the ACRA is done.
|
T |
setApplicationLogFile(java.lang.String applicationLogFile)
To use in combination with
ReportField.APPLICATION_LOG to set the
path/name of your application log file. |
T |
setApplicationLogFileDir(Directory applicationLogFileDir)
To use in combination with
ReportField.APPLICATION_LOG to set the root
for the path provided in applicationLogFile() |
T |
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. |
T |
setAttachmentUriProvider(java.lang.Class<? extends AttachmentUriProvider> attachmentUriProvider)
Allows attachmentUri configuration at runtime instead of compile time.
|
T |
setAttachmentUris(java.lang.String... attachmentUris)
Allows to attach files to crash reports.
|
T |
setBuildConfigClass(java.lang.Class buildConfigClass)
The default value will be a BuildConfig class residing in the same package as the Application class.
|
T |
setCertificatePath(java.lang.String certificatePath) |
T |
setCertificateType(java.lang.String certificateType) |
T |
setConnectionTimeout(int connectionTimeout) |
T |
setCustomReportContent(ReportField... customReportContent)
Redefines the list of
ReportField s collected and sent in your
reports. |
T |
setDeleteOldUnsentReportsOnApplicationStart(boolean deleteOldUnsentReportsOnApplicationStart)
This property can be used to determine whether old (out of date) reports
should be sent or not.
|
T |
setDeleteUnapprovedReportsOnApplicationStart(boolean deleteUnapprovedReportsOnApplicationStart)
Controls whether unapproved reports are deleted on application start or not.
|
T |
setDropboxCollectionMinutes(int dropboxCollectionMinutes) |
T |
setExcludeMatchingSettingsKeys(java.lang.String... excludeMatchingSettingsKeys)
Provide here regex patterns to be evaluated on each Settings.System,
Settings.Secure and Settings.Global key to exclude KV pairs from the
collected SharedPreferences.
|
T |
setExcludeMatchingSharedPreferencesKeys(java.lang.String... excludeMatchingSharedPreferencesKeys)
Provide here regex patterns to be evaluated on each SharedPreference key
to exclude KV pairs from the collected SharedPreferences.
|
T |
setFormUri(java.lang.String formUri)
The Uri of your own server-side script that will receive reports.
|
T |
setFormUriBasicAuthLogin(java.lang.String formUriBasicAuthLogin)
When using the
formUri() parameter to send reports to a custom
server-side script, you can set here and in
formUriBasicAuthPassword() the credentials for a BASIC HTTP
authentication. |
T |
setFormUriBasicAuthPassword(java.lang.String formUriBasicAuthPassword)
When using the
formUri() parameter to send reports to a custom
server-side script, you can set here and in
formUriBasicAuthLogin() the credentials for a BASIC HTTP
authentication. |
T |
setHttpMethod(HttpSender.Method httpMethod)
The
HttpSender.Method to be used when posting with formUri() . |
T |
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
|
T |
setKeyStoreFactoryClass(java.lang.Class<? extends KeyStoreFactory> keyStoreFactoryClass) |
T |
setLogcatArguments(java.lang.String... logcatArguments)
Arguments to be passed to the logcat command line.
|
T |
setLogcatFilterByPid(boolean logcatFilterByPid)
Set this to true if you want to include only logcat lines related to your
Application process.
|
T |
setMailTo(java.lang.String mailTo)
Add your crash reports mailbox here if you want to send reports via
email.
|
T |
setNonBlockingReadForLogcat(boolean nonBlockingReadForLogcat)
Set this to true if you want to read logcat lines in a non blocking way for your
thread.
|
T |
setReportAsFile(boolean reportAsFile) |
T |
setReportDialogClass(java.lang.Class<? extends BaseCrashReportDialog> reportDialogClass) |
T |
setReportingInteractionMode(ReportingInteractionMode reportingInteractionMode)
The interaction mode you want to implement.
|
T |
setReportPrimerClass(java.lang.Class<? extends ReportPrimer> reportPrimerClass) |
T |
setReportSenderFactoryClasses(java.lang.Class<? extends ReportSenderFactory>... reportSenderFactoryClasses)
The default
ReportSenderFactory creates an EmailIntentSender
if the 'mailTo' parameter is defined or an HttpSender if the 'formUri' parameter
is defined (and internet permission has been granted. |
T |
setReportType(HttpSender.Type reportType)
The
HttpSender.Type to be used when posting with formUri() . |
T |
setResCertificate(int resCertificate) |
T |
setResDialogCommentPrompt(int resDialogCommentPrompt) |
T |
setResDialogEmailPrompt(int resDialogEmailPrompt) |
T |
setResDialogIcon(int resDialogIcon) |
T |
setResDialogNegativeButtonText(int resDialogNegativeButtonText) |
T |
setResDialogOkToast(int resDialogOkToast) |
T |
setResDialogPositiveButtonText(int resDialogPositiveButtonText) |
T |
setResDialogText(int resDialogText) |
T |
setResDialogTheme(int resDialogTheme) |
T |
setResDialogTitle(int resDialogTitle) |
T |
setResNotifIcon(int resNotifIcon) |
T |
setResNotifText(int resNotifText) |
T |
setResNotifTickerText(int resNotifTickerText) |
T |
setResNotifTitle(int resNotifTitle) |
T |
setResToastText(int resToastText)
Resource id for the Toast text triggered when the application crashes if
the
ReportingInteractionMode.TOAST mode is used. |
T |
setRetryPolicyClass(java.lang.Class<? extends RetryPolicy> retryPolicyClass) |
T |
setSendReportsInDevMode(boolean sendReportsInDevMode)
Set this to false if you want to disable sending reports in development
mode.
|
T |
setSharedPreferencesMode(int sharedPreferencesMode)
If using a custom
ReportsCrashes.sharedPreferencesName() , pass
here the mode that you need for the SharedPreference file creation:
Context.MODE_PRIVATE , Context.MODE_WORLD_READABLE or
Context.MODE_WORLD_WRITEABLE . |
T |
setSharedPreferencesName(java.lang.String sharedPreferencesName) |
T |
setSocketTimeout(int socketTimeout)
If the request is retried due to timeout, the socketTimeout will double
before retrying the request.
|
T |
setStopServicesOnCrash(boolean stopServicesOnCrash) |
public BaseConfigurationBuilder(@NonNull android.app.Application app)
public T setFormUri(@NonNull java.lang.String formUri)
formUri
- URI of a custom server to which to post reports.public T setReportingInteractionMode(@NonNull ReportingInteractionMode reportingInteractionMode)
The interaction mode you want to implement. Default is
ReportingInteractionMode.SILENT
which does not require any
resources configuration.
Other modes have resources requirements:
ReportingInteractionMode.TOAST
requires
resToastText()
to be provided to define the text that you want
to be displayed to the user when a report is being sent.ReportingInteractionMode.NOTIFICATION
requires
resNotifTickerText()
, resNotifTitle()
,
resNotifText()
, resDialogText()
.ReportingInteractionMode.DIALOG
requires
resDialogText()
.
Default is ReportingInteractionMode.SILENT
reportingInteractionMode
- the interaction mode that you want ACRA to implement.public T setResDialogPositiveButtonText(@StringRes int resDialogPositiveButtonText)
resDialogPositiveButtonText
- Resource id for the label of positive button in the crash dialog.
If not provided, defaults to 'OK'.public T setResDialogNegativeButtonText(@StringRes int resDialogNegativeButtonText)
resDialogNegativeButtonText
- Resource id for the label of negative button in the crash dialog.
If not provided, defaults to 'cancel'.public T setResDialogCommentPrompt(@StringRes int resDialogCommentPrompt)
resDialogCommentPrompt
- Resource id for the user comment input label in the crash dialog.
If not provided, disables the input field.public T setResDialogEmailPrompt(@StringRes int resDialogEmailPrompt)
resDialogEmailPrompt
- Resource id for the user email address input label in the crash
dialog. If not provided, disables the input field.public T setResDialogIcon(@DrawableRes int resDialogIcon)
resDialogIcon
- Resource id for the icon in the crash dialog. Default value is
the system alert icon.public T setResDialogOkToast(@StringRes int resDialogOkToast)
resDialogOkToast
- Resource id for the Toast text triggered when the user accepts to
send a report in the crash dialog.public T setResDialogText(@StringRes int resDialogText)
resDialogText
- Resource id for the text in the crash dialog.public T setResDialogTitle(@StringRes int resDialogTitle)
resDialogTitle
- Resource id for the title in the crash dialog.public T setResDialogTheme(@StyleRes int resDialogTheme)
resDialogTheme
- resource id for the crash dialog themepublic T setResNotifIcon(@DrawableRes int resNotifIcon)
resNotifIcon
- Resource id for the icon in the status bar notification. Default
is the system error notification icon.public T setResNotifText(@StringRes int resNotifText)
resNotifText
- Resource id for the text in the status bar notification.public T setResNotifTickerText(@StringRes int resNotifTickerText)
resNotifTickerText
- Resource id for the ticker text in the status bar notification.public T setResNotifTitle(@StringRes int resNotifTitle)
resNotifTitle
- Resource id for the title in the status bar notification.public T setResToastText(@StringRes int resToastText)
ReportingInteractionMode.TOAST
mode is used. Can also be used
in ReportingInteractionMode.NOTIFICATION
and
ReportingInteractionMode.DIALOG
modes to display a Toast message
while the report is being created, before the dialog/notification
appears. This allows the user to know what is happening just before the
application is terminated.resToastText
- Resource id for the Toast text triggered when the application
crashes.public T setSharedPreferencesName(@NonNull java.lang.String sharedPreferencesName)
sharedPreferencesName
- Name of the SharedPreferences that will host ACRA settings 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
PreferenceManager.getDefaultSharedPreferences(android.content.Context)
.public T setSharedPreferencesMode(int sharedPreferencesMode)
ReportsCrashes.sharedPreferencesName()
, pass
here the mode that you need for the SharedPreference file creation:
Context.MODE_PRIVATE
, Context.MODE_WORLD_READABLE
or
Context.MODE_WORLD_WRITEABLE
. Default is
Context.MODE_PRIVATE
.sharedPreferencesMode
- Mode to use with the SharedPreference creation.Context.getSharedPreferences(String, int)
public T setIncludeDropBoxSystemTags(boolean includeDropBoxSystemTags)
includeDropBoxSystemTags
- True if system tags are to be included as part of DropBox events.public T setAdditionalDropBoxTags(@NonNull java.lang.String... additionalDropBoxTags)
additionalDropBoxTags
- Array of tags that you want to be fetched when collecting DropBox
entries.public T setDropboxCollectionMinutes(int dropboxCollectionMinutes)
dropboxCollectionMinutes
- Number of minutes to look back when collecting events from
DropBoxManager.public T setLogcatArguments(@NonNull java.lang.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
ReportsCrashes.customReportContent()
to activate alternative
logcat buffers reporting. They will use the same other arguments as those
provided here.
logcatArguments
- Array of arguments to supply if retrieving the log as part of the
report.public T setFormUriBasicAuthLogin(@NonNull java.lang.String formUriBasicAuthLogin)
formUri()
parameter to send reports to a custom
server-side script, you can set here and in
formUriBasicAuthPassword()
the credentials for a BASIC HTTP
authentication.formUriBasicAuthLogin
- Login to use when posting reports to a custom server.public T setFormUriBasicAuthPassword(@NonNull java.lang.String formUriBasicAuthPassword)
formUri()
parameter to send reports to a custom
server-side script, you can set here and in
formUriBasicAuthLogin()
the credentials for a BASIC HTTP
authentication.formUriBasicAuthPassword
- Password to use when posting reports to a custom server.public T setCustomReportContent(@NonNull ReportField... customReportContent)
Redefines the list of ReportField
s collected and sent in your
reports.
The fields order is significant. You can also use this property to modify fields order in your reports.
The default list is the following, except if you send reports by mail
using mailTo()
.
ReportField.REPORT_ID
ReportField.APP_VERSION_CODE
ReportField.APP_VERSION_NAME
ReportField.PACKAGE_NAME
ReportField.FILE_PATH
ReportField.PHONE_MODEL
ReportField.BRAND
ReportField.PRODUCT
ReportField.ANDROID_VERSION
ReportField.BUILD
ReportField.TOTAL_MEM_SIZE
ReportField.AVAILABLE_MEM_SIZE
ReportField.CUSTOM_DATA
ReportField.IS_SILENT
ReportField.STACK_TRACE
ReportField.INITIAL_CONFIGURATION
ReportField.CRASH_CONFIGURATION
ReportField.DISPLAY
ReportField.USER_COMMENT
ReportField.USER_EMAIL
ReportField.USER_APP_START_DATE
ReportField.USER_CRASH_DATE
ReportField.DUMPSYS_MEMINFO
ReportField.LOGCAT
ReportField.INSTALLATION_ID
ReportField.DEVICE_FEATURES
ReportField.ENVIRONMENT
ReportField.SHARED_PREFERENCES
ReportField.SETTINGS_SYSTEM
ReportField.SETTINGS_SECURE
ReportField.SETTINGS_GLOBAL
customReportContent
- ReportField Array listing the fields to be included in the
report.public T setMailTo(@NonNull java.lang.String mailTo)
Add your crash reports mailbox here if you want to send reports via
email. This allows to get rid of the INTERNET permission. Reports content
can be customized with customReportContent()
. Default fields
are:
mailTo
- email address to which to send reports.public T setDeleteUnapprovedReportsOnApplicationStart(boolean deleteUnapprovedReportsOnApplicationStart)
Silent and Toast reports are automatically approved. Dialog and Notification reports required explicit approval by the user before they are sent.
On application restart the user is prompted with approval for any unsent reports. 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.
If set to false then on restart the user will be prompted with approval for each unapproved report.
deleteUnapprovedReportsOnApplicationStart
- true if ACRA should delete unapproved reports on application start.public T setDeleteOldUnsentReportsOnApplicationStart(boolean deleteOldUnsentReportsOnApplicationStart)
deleteOldUnsentReportsOnApplicationStart
- true if ACRA should delete any unsent reports on startup if the
application has been updated since the last time the application
was started.public T setConnectionTimeout(int connectionTimeout)
connectionTimeout
- Value in milliseconds for timeout attempting to connect to a network (default 5000ms).public T setSocketTimeout(int socketTimeout)
socketTimeout
- Value in milliseconds for timeout receiving a response to a network request (default 8000ms).public T setAlsoReportToAndroidFramework(boolean alsoReportToAndroidFramework)
ReportingInteractionMode.DIALOG
for notification.alsoReportToAndroidFramework
- true if the native force close dialog should be displayed.public T setAdditionalSharedPreferences(@NonNull java.lang.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
- String Array containing the names of the additional preferences.public T setLogcatFilterByPid(boolean logcatFilterByPid)
logcatFilterByPid
- true if you want to filter logcat with your process id.public T setNonBlockingReadForLogcat(boolean nonBlockingReadForLogcat)
nonBlockingReadForLogcat
- true if you want that reading of logcat lines to not block current thread.public T setSendReportsInDevMode(boolean sendReportsInDevMode)
sendReportsInDevMode
- false if reports should not be sent.public T setExcludeMatchingSharedPreferencesKeys(@NonNull java.lang.String... excludeMatchingSharedPreferencesKeys)
excludeMatchingSharedPreferencesKeys
- an array of regex patterns, every matching key is not collected.public T setExcludeMatchingSettingsKeys(@NonNull java.lang.String... excludeMatchingSettingsKeys)
excludeMatchingSettingsKeys
- an array of regex patterns, every matching key is not collected.public T setBuildConfigClass(@NonNull java.lang.Class buildConfigClass)
buildConfigClass
- BuildConfig class from which to read any BuildConfig attributes.public T setReportSenderFactoryClasses(@NonNull java.lang.Class<? extends ReportSenderFactory>... reportSenderFactoryClasses)
ReportSenderFactory
creates an EmailIntentSender
if the 'mailTo' parameter is defined or an HttpSender
if the 'formUri' parameter
is defined (and internet permission has been granted.reportSenderFactoryClasses
- List of the ReportSenderFactory
with which to construct the
ReportSender
s that will send the crash reports.public T setApplicationLogFile(@NonNull java.lang.String applicationLogFile)
ReportField.APPLICATION_LOG
to set the
path/name of your application log file. If the string does not contain
any path separator, the file is assumed as being in
Context.getFilesDir()
.applicationLogFile
- a String containing the path/name of your application log file.
If the string does not contain any path separator, the file is
assumed as being in Context.getFilesDir()
.public T 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.public T setApplicationLogFileDir(@NonNull Directory applicationLogFileDir)
ReportField.APPLICATION_LOG
to set the root
for the path provided in applicationLogFile()
applicationLogFileDir
- the directory of the application log filepublic T setReportDialogClass(@NonNull java.lang.Class<? extends BaseCrashReportDialog> reportDialogClass)
reportDialogClass
- Class for the CrashReportDialog used when prompting the user for crash details.
If not provided, defaults to CrashReportDialog.classpublic T setReportPrimerClass(@NonNull java.lang.Class<? extends ReportPrimer> reportPrimerClass)
reportPrimerClass
- Class that is ued to provide any extra details for a crash.public T setHttpMethod(@NonNull HttpSender.Method httpMethod)
The HttpSender.Method
to be used when posting with formUri()
.
httpMethod
- HTTP method used when posting reports.public T setReportType(@NonNull HttpSender.Type reportType)
The HttpSender.Type
to be used when posting with formUri()
.
reportType
- the report type used when posting reportspublic T setKeyStoreFactoryClass(@NonNull java.lang.Class<? extends KeyStoreFactory> keyStoreFactoryClass)
keyStoreFactoryClass
- Class which creates a keystore that can contain trusted certificatespublic T setCertificatePath(@NonNull java.lang.String certificatePath)
certificatePath
- path to a custom trusted certificate. Must start with "asset://" if the file is in the assets folderpublic T setResCertificate(@RawRes int resCertificate)
resCertificate
- resource id of a custom trusted certificate.public T setCertificateType(@NonNull java.lang.String certificateType)
certificateType
- specify the type of the certificate set in either certificatePath()
or resCertificate()
public T setRetryPolicyClass(@NonNull java.lang.Class<? extends RetryPolicy> retryPolicyClass)
retryPolicyClass
- a Class that decides if a report should be resent (usually if one or more senders failed).public T setStopServicesOnCrash(boolean stopServicesOnCrash)
stopServicesOnCrash
- true if all services running in a process should be stopped before it is killed.public T setAttachmentUris(@NonNull java.lang.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.provider/files/thisIsATest.txt
attachmentUris
- uris to be attached to crash reports.public T setAttachmentUriProvider(@NonNull java.lang.Class<? extends AttachmentUriProvider> attachmentUriProvider)
attachmentUriProvider
- a class that decides which uris should be attached to reportspublic T setReportAsFile(boolean reportAsFile)
reportAsFile
- if the report should be an attachment instead of plain text. Supported for email mode.