简体   繁体   English

如何在 android 中获取最近活跃的应用程序?

[英]How to get recent active apps in android?

How we find recently running application.我们如何找到最近运行的应用程序。 I use this code but show only working app.我使用此代码,但仅显示有效的应用程序。

final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);

for (int i = 0; i < recentTasks.size(); i++) 
{
    Log.d("Executed app", "Application executed : " 
            + recentTasks.get(i).baseActivity.toShortString()
            + "\t\t ID: "+recentTasks.get(i).id+"");         
}

I found something in here which should help:我在这里找到了一些应该有帮助的东西:

https://gist.github.com/rmkrishna/7e133bcf1a918a02f2c882c1d7011b18 https://gist.github.com/rmkrishna/7e133bcf1a918a02f2c882c1d7011b18

First of all, it gets all recent apps.首先,它会获取所有最近的应用程序。

It has the Android Manifest and Java code.它具有Android ManifestJava代码。

I think it's fine to give you this since the contributor has been gone for several months now.我认为给你这个很好,因为贡献者已经离开几个月了。

I thought of giving you this link since I read in your comment that yours only shows working apps, if that above doesn't want to work...我想给你这个链接,因为我在你的评论中读到你的评论只显示工作应用程序,如果上面不想工作的话......

Tell me, I'll offer an alternative.告诉我,我会提供一个替代方案。

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

相关问题 如何在Android Studio中以编程方式锁定近期应用中的应用 - How to lock app in recent apps programmatically in android studio 如何避免我的android应用程序显示在“最近的应用程序”列表中? - How to avoid my android application to be shown in the “recent apps” list? 如何处理android studio中最近的应用程序导航按钮? - How to handle recent apps navigation button in android studio? 如何从“最近打开的应用”中获取屏幕截图? - How can I get screenshot's from “Recent opened apps”? 如何在我的 android 应用程序中获取最近的参与者? - How to get recent participants in my android app? 在android中处理最近的应用程序点击和主页按下 - Handle Recent apps click and home press in android Android:自定义最近的应用程序缩略图(默认截图) - Android: Customizing recent apps thumbnail (screenshot by default) 获取用户最近启动的应用程序列表 - get list of recent apps that were launched by user Android-如何关闭Google Pixel 2上的首页/后退/最新应用程序按钮指示灯 - Android - How to turn off home/back/recent apps buttons light on Google Pixel 2 如何长按主页,后退或最近的应用程序按钮打开我的Android应用程序? - How to open my Android app on a long press of home, back or recent apps button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM