如何检查在目前的Android运行的应用程序?
问题描述:
我要检查在目前的Android运行的应用程序编程方式,类似于它是如何显示,如果我们preSS 6应用程序,按住首页按钮。
I want to check current running applications in android programmatically, similar to how it shows 6 applications if we press and hold the HOME button.
我最感兴趣的是应用程序的名称。
I'm mostly interested in the application names.
答
您可以使用现名包
ActivityManager am = (ActivityManager) mContext
.getSystemService(Activity.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity
.getPackageName();
您可以使用此包名称来获得当前活动的应用程序
You can use this package name to get current active application