-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: CannotDeliverBroadcastException 수정
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/easyhz/picly/util/exception/PiclyUncaughtExceptionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.easyhz.picly.util.exception | ||
|
||
class PiclyUncaughtExceptionHandler( | ||
private val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler | ||
) : Thread.UncaughtExceptionHandler { | ||
|
||
override fun uncaughtException(thread: Thread, exception: Throwable) { | ||
if (shouldAbsorb(exception)) { | ||
return | ||
} | ||
uncaughtExceptionHandler.uncaughtException(thread, exception) | ||
} | ||
|
||
/** | ||
* Evaluate whether to silently absorb uncaught crashes such that they | ||
* don't crash the app. We generally want to avoid this practice - we would | ||
* rather know about them. However in some cases there's nothing we can do | ||
* about the crash (e.g. it is an OS fault) and we would rather not have them | ||
* pollute our reliability stats. | ||
*/ | ||
private fun shouldAbsorb(exception: Throwable): Boolean { | ||
return when (exception::class.simpleName) { | ||
"CannotDeliverBroadcastException" -> true | ||
else -> false | ||
} | ||
} | ||
|
||
} |