Can a custom View know that onPause has been called?

后端 未结 6 2238
南方客
南方客 2021-02-03 18:52

I have a custom View that runs a Thread operation which sits around making calls to the interwebs periodically. I would like to know if there\'s a way for me to not have to kil

6条回答
  •  滥情空心
    2021-02-03 19:08

    Either you have to let your view know that the owning Activity is not in the foreground any more, or poll the system with some method to query about which task is currently in the foreground, which seems highly inefficient.

    Here are two links that have addressed this issue:

    • How to check if activity is in foreground or in visible background?
    • Checking if an Android application is running in the background

    (This might not really be an answer, but it was too large for a comment)

提交回复
热议问题