Resolve too many Widget threads
This commit is contained in:
parent
ea156511e0
commit
1c94a20a5c
1 changed files with 5 additions and 1 deletions
|
@ -54,7 +54,11 @@ class Widget : AppWidgetProvider() {
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
|
|
||||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
companion object {
|
||||||
|
// This object doesn't behave like singleton,
|
||||||
|
// many threads were created. Making handler static resolve this issue
|
||||||
|
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||||
|
}
|
||||||
private val intentAction = "OpenApp"
|
private val intentAction = "OpenApp"
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent?) {
|
override fun onReceive(context: Context, intent: Intent?) {
|
||||||
|
|
Loading…
Reference in a new issue