开发者

How to programmatically determine the currently active App in Android

开发者 https://www.devze.com 2023-02-19 14:09 出处:网络
Is there a way to find the app whose activity is curre开发者_如何学Gontly active in android? Does android send a broadcast when a new app/activity is active?Call ActivityManager.getRunningAppProcesses

Is there a way to find the app whose activity is curre开发者_如何学Gontly active in android? Does android send a broadcast when a new app/activity is active?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消