0

我想知道服务中当前手机的界面上显示了哪些活动。

android中有活动堆栈。它是否在系统中有一个全局活动堆栈并提供前台显示的活动信息?

4

1 回答 1

2
Context context = null; // FIXME: init with your context.
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
        for (int i = 0; i < procInfos.size(); i++) {
            if (procInfos.get(i).importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
                //the current running process
                Log.d("FOREGROUND_Application", procInfos.get(i).processName + "is running on the FOREGROUND");
            }
        }
于 2012-12-17T08:15:28.000 回答