1

Is there a alternative way for looper.quitSafely() in below android API 17 ?

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
ali
  • 11
  • 1

1 Answers1

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