Last active
March 18, 2020 22:45
-
-
Save jraska/b86f020095157f21503bee502d847b69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TopActivityProvider { | |
var topActivity: Activity? = null | |
private set | |
private val callbacks: Application.ActivityLifecycleCallbacks = object : ActivityLifecycleCallbacks { | |
override fun onActivityResumed(activity: Activity) { | |
topActivity = activity | |
} | |
override fun onActivityPaused(activity: Activity) { | |
topActivity = null | |
} | |
// Other methods are empty | |
} | |
private fun setupWith(app: Application) { | |
app.registerActivityLifecycleCallbacks(callbacks) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment