Reputation: 11
Is there a way to find the app whose activity is currently active in android? Does android send a broadcast when a new app/activity is active?
Upvotes: 1
Views: 7394
Reputation: 77752
Call ActivityManager.getRunningAppProcesses()
, then iterate through the ActivityManager.RunningAppProcessInfo
objects and look for the one(s) with IMPORTANCE_FOREGROUND
.
I'm not sure if there are situations (tablet? Laptop dock?) when you can have multiple foreground activities.
Upvotes: 5