Skip to content

Commit 5c575d8

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents ca301fd + cc44f87 commit 5c575d8

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

readme.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,64 @@
1-
# Global Exception Handler
21

2+
# GlobalExceptionHandler
33

4+
![header](https://github.com/Alonew0lfxx/GlobalExceptionHandler/blob/c56bf46d4497edb24425896abf680cc3155a7579/assets/header.png?raw=true)
45

6+
Rather than showing the default boring system error dialog, it serves to open the
7+
desired Activity whenever the Application crashes. And it has only 2 functions
58

69

710

811

12+
## Usage/Examples
13+
14+
App.kt
15+
```kotlin
16+
class App : Application() {
17+
override fun onCreate() {
18+
super.onCreate()
19+
GlobalExceptionHandler.initialize(this,CrashActivity::class.java)
20+
}
21+
}
22+
```
23+
24+
App.kt
25+
```kotlin
26+
class CrashActivity : AppCompatActivity() {
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
GlobalExceptionHandler.getThrowableFromIntent(intent).let { throwable ->
30+
// Report the crash error to your servers or etc...
31+
}
32+
setContentView(view)
33+
}
34+
```
35+
36+
37+
## Functions
38+
39+
#### Initalize the GlobalExceptionHandler
40+
41+
```kotlin
42+
GlobalExceptionHandler.initalize(applicationContext, activityToBeLaunched)
43+
```
44+
45+
| Parameter | Type | Description |
46+
| :-------- | :------- | :------------------------- |
47+
| `applicationContext` | `Context` | Required to launch Intent |
48+
| `activityToBeLaunched` | `Activity` | The activity to be launched whenerver app crashes |
49+
50+
#### Get Throwable from Intent
51+
52+
```kotlin
53+
GlobalExceptionHandler.getThrowableFromIntent(intent): Throwable?
54+
```
55+
56+
| Parameter | Type | Description |
57+
| :-------- | :------- | :-------------------------------- |
58+
| `intent` | `Intent` | Retrives crash data from intent. It should be called inside of the **activityToBeLaunched** Activity. |
59+
60+
## Screenshots
61+
With GlobalExceptionHandler | Without GlobalExceptionHandler
62+
--- | ---
63+
![](https://github.com/Alonew0lfxx/GlobalExceptionHandler/blob/master/assets/gif1.gif?raw=true) | ![](https://github.com/Alonew0lfxx/GlobalExceptionHandler/blob/master/assets/gif0.gif?raw=true)
64+

0 commit comments

Comments
 (0)