简体   繁体   English

获取用户最近启动的应用程序列表

[英]get list of recent apps that were launched by user

in my app ,i want to get a list of apps that were recently launched by user. 在我的应用程序中,我想获取用户最近启动的应用程序列表。 for now,just log this list. 现在,只需记录此列表。

i searched about it. 我搜索了它。 and i found this code: 我发现此代码:

ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> runningProcessInfo = am.getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo processInfo : runningProcessInfo) {
            Log.d("Nitin", processInfo.processName);
        }

but this code only prints my app name. 但是此代码仅显示我的应用名称。 ie com.tracker.appcount.apptracker so it means that my runningProcessInfo list is only of size 1. 即com.tracker.appcount.apptracker,因此这意味着我的runningProcessInfo列表的大小仅为1。

i don't know where i am wrong?repeatedly i saw answer of this format.and in some posts it was accomplished using getRecentsTasks function which is now deprecated so it's of no use. 我不知道我在哪里错?重复地,我看到了这种格式的答案。在某些帖子中,它是使用getRecentsTasks函数完成的,该函数现已被弃用,因此没有用。 please help me on this one. 请帮助我这一件事。

Evrything is deprecated for security reasons. 由于安全原因,不推荐使用Evrything。 If you want to know about things happening on your phone, root it and use a shell to get what you need 如果您想了解手机上发生的事情,请启动它并使用外壳获取所需的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM