Is there a alternative way for looper.quitSafely()
in below android API 17 ?
Asked
Active
Viewed 247 times
1

Hemant Parmar
- 3,924
- 7
- 25
- 49

ali
- 11
- 1
-
yes, `Looper#quit()` – pskink May 29 '18 at 05:56
-
No, the Looper#quit() close looper immediate and not run enqueue messages, I need stop looper after all message handled. – ali May 29 '18 at 06:34
-
this is the only thing you can do – pskink May 29 '18 at 06:37
1 Answers
0
First, it's not below API 17. It's below 18.
Second, there is a way:
private val backgroundHandler: Handler
private val backgroundHandlerThread = HandlerThread("ICEManagerWrapper")
fun stop() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
backgroundHandlerThread.quitSafely()
else
backgroundHandler.post {
backgroundHandlerThread.quit()
}
}

android developer
- 114,585
- 152
- 739
- 1,270