how to stop Handler in Android?

后端 未结 6 1289
名媛妹妹
名媛妹妹 2020-12-08 09:32

In My Application my handler doesn\'t stop. How can I stop the handler?
It continues to start after closing the activity. What can i do?

the code is :



        
6条回答
  •  星月不相逢
    2020-12-08 10:15

    Your Handler (if implemented like this) will be active as long as the Looper instance is active, which is for the whole life cycle of the thread (which has little to do with activity life cycle).

    If you want the handler to stop re-triggering itself, you need to take care of it yourself.

    Sending 0-delayed message to self looks slightly weird, anyway. What are you trying to achieve, actually?

提交回复
热议问题