开发者

How to programmatically determine the currently active App in Android

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜