feat: Add crash saving (#12)

This commit is contained in:
2023-08-24 15:54:55 +02:00
committed by GitHub
parent 1703479865
commit acbb524a7e
16 changed files with 383 additions and 130 deletions

View File

@ -24,7 +24,7 @@ Lightweight & customizable crash android crash handler library
Add to you dependencies (check the latest release for the version):
- (Gradle Kotlin DSL) Add `implementation("com.dzeio:crashhandler:1.0.2")`
- (Gradle Groovy DSL) Add `implementation "com.dzeio:crashhandler:1.0.2" `
- (Gradle Groovy DSL) Add `implementation "com.dzeio:crashhandler:1.0.2"`
## Usage
@ -33,25 +33,32 @@ _note: full featured example in the `sample` app_
Create and add this to your Application.{kt,java}
```kotlin
// create the Crash Handler
CrashHandler.Builder()
// need the application context to run
.withContext(this)
// every other items below are optionnal
// define a custom activity to use
.withActivity(ErrorActivity::class.java)
// need the application context to run
.withContext(this)
// every other items below are optionnal
// define a custom activity to use
.withActivity(ErrorActivity::class.java)
// define the preferenceManager to be able to handle crash in a custom Activity and to have the previous crash date in the logs
.withPrefs(prefs)
.withPrefsKey("com.dzeio.crashhandler.key")
// define the preferenceManager to have the previous crash date in the logs
.withPrefs(prefs)
.withPrefsKey("com.dzeio.crashhandler.key")
// a Prefix to add at the beggining the crash message
.withPrefix("Pouet :D")
// a Prefix to add at the beginning the crash message
.withPrefix("Prefix")
// a Suffic to add at the end of the crash message
.withSuffix("WHYYYYY")
// a Suffix to add at the end of the crash message
.withSuffix("Suffix")
// add a location where the crash logs are also exported (can be recovered as a zip ByteArray by calling {CrashHandler.getInstance().export()})
.withExportLocation(
File(this.getExternalFilesDir(null) ?: this.filesDir, "crash-logs")
)
// build & start the module
.build().setup()
// build & start the module
.build().setup()
```
## Build