How to detect if any of my activity is front-most and visible to user?

前端 未结 5 1277
醉酒成梦
醉酒成梦 2020-11-29 08:19

I would like to launch an intent when any of my activity is visible, otherwise I will put it up as a notification, and will be fired by the user.

To decide this, I

5条回答
  •  粉色の甜心
    2020-11-29 08:41

    onResume() called && onPause() not called = visible.
    Have a public static Activity currentlyVisible; in your Application subclass that will be updated by your activities (set to the instance in onResume() and nulled in onPause()). Or invent a less ugly variant of a registry.

提交回复
热议问题