public class ErrorReporterImpl extends Object implements Thread.UncaughtExceptionHandler, SharedPreferences.OnSharedPreferenceChangeListener, ErrorReporter
The ErrorReporter is a Singleton object in charge of collecting crash context
data and sending crash reports. It registers itself as the Application's
Thread default Thread.UncaughtExceptionHandler
.
When a crash occurs, it collects data of the crash context (device, system, stack trace...) and writes a report file in the application private directory, which may then be sent.
Constructor and Description |
---|
ErrorReporterImpl(Application context,
CoreConfiguration config,
boolean enabled,
boolean supportedAndroidVersion,
boolean checkReportsOnApplicationStart) |
Modifier and Type | Method and Description |
---|---|
void |
clearCustomData()
Removes all key/value pairs from your reports custom data field.
|
String |
getCustomData(String key)
Gets the current value for a key in your reports custom data field.
|
SenderScheduler |
getReportScheduler()
Access point to manual report scheduling
|
void |
handleException(Throwable e)
Send a normal report for the given exception.
|
void |
handleException(Throwable e,
boolean endApplication)
Send a normal report for the given exception
|
void |
handleSilentException(Throwable e)
Send a silent report for the given exception
|
void |
onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) |
String |
putCustomData(String key,
String value)
Use this method to provide the ErrorReporter with data of your running application.
|
String |
removeCustomData(String key)
Removes a key/value pair from your reports custom data field.
|
void |
setEnabled(boolean enabled)
Enable or disable this ErrorReporter.
|
void |
uncaughtException(Thread t,
Throwable e) |
void |
unregister() |
public ErrorReporterImpl(@NonNull Application context, @NonNull CoreConfiguration config, boolean enabled, boolean supportedAndroidVersion, boolean checkReportsOnApplicationStart)
context
- Context for the application in which ACRA is running.config
- AcraConfig to use when reporting and sending errors.enabled
- Whether this ErrorReporter should capture Exceptions and forward their reports.supportedAndroidVersion
- the minimal supported versionpublic String putCustomData(@NonNull String key, @Nullable String value)
putCustomData
in interface ErrorReporter
key
- A key for your custom data.value
- The value associated to your key.ErrorReporter.removeCustomData(String)
,
ErrorReporter.getCustomData(String)
@Nullable public String removeCustomData(@NonNull String key)
removeCustomData
in interface ErrorReporter
key
- The key of the data to be removed.ErrorReporter.putCustomData(String, String)
,
ErrorReporter.getCustomData(String)
public void clearCustomData()
clearCustomData
in interface ErrorReporter
@Nullable public String getCustomData(@NonNull String key)
getCustomData
in interface ErrorReporter
key
- The key of the data to be retrieved.ErrorReporter.putCustomData(String, String)
,
ErrorReporter.removeCustomData(String)
public void uncaughtException(@Nullable Thread t, @NonNull Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
public void handleSilentException(@Nullable Throwable e)
handleSilentException
in interface ErrorReporter
e
- The Throwable
to be reported. If null the report will contain a new Exception("Report requested by developer").public void setEnabled(boolean enabled)
setEnabled
in interface ErrorReporter
enabled
- Whether this ErrorReporter should capture Exceptions and forward them as crash reports.public void handleException(@Nullable Throwable e, boolean endApplication)
handleException
in interface ErrorReporter
e
- The Throwable
to be reported. If null the report will contain a new Exception("Report requested by developer").endApplication
- if you want the application to be ended after sending the report.public void handleException(@Nullable Throwable e)
handleException
in interface ErrorReporter
e
- The Throwable
to be reported. If null the report will contain a new Exception("Report requested by developer").public SenderScheduler getReportScheduler()
ErrorReporter
getReportScheduler
in interface ErrorReporter
public void onSharedPreferenceChanged(@NonNull SharedPreferences sharedPreferences, @Nullable String key)
onSharedPreferenceChanged
in interface SharedPreferences.OnSharedPreferenceChangeListener
public void unregister()