简单直接的答案: override fun onPause() { Log.i("APP LIFECYCLE", "App Enter BACKground") isForeground = false super.onPause() } override fun onResume() { Log.i("APP LIFECYCLE", "App Enter FOREground") isForeground = true super.onResume() } 然后只需使用 isForeground 活动的属性来检查状态。 原文由 SHANNAX 发布,翻译遵循 CC BY-SA 4.0 许可协议
简单直接的答案:
然后只需使用
isForeground
活动的属性来检查状态。