Should I manually close HandlerThreads created by my application when destroying the activity?

后端 未结 5 2286
独厮守ぢ
独厮守ぢ 2021-02-20 02:49

My app is composed of a single Activity. In this activity, I\'m creating multiple HandlerThreads which run in a loop to do socket blocking operations.<

5条回答
  •  轮回少年
    2021-02-20 03:24

    The best practices approach would be to remove the callbacks to your handlers in your activities onDestroy(). See this answer for more:

    https://stackoverflow.com/a/5038542/1369222

提交回复
热议问题