How to stop a running thread when Activity on destroy at Android?

前端 未结 4 1844
一生所求
一生所求 2020-12-17 04:15

I used some thread objects in my Android activity. But these threads do not stop itself when Activity on destroy. My code for thread-stopping as following:



        
4条回答
  •  抹茶落季
    2020-12-17 05:05

    Adding finish(); should end the Activity when onDestroy() or anything else (eg. a button is pressed) is called. When you use onDestroy(), make sure super.onDestroy(); is put after everything else is called.

提交回复
热议问题