How do I get the package of running apps? I have managed to get the names, but can’t find how to get package. Here’s my code.
ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List list = am.getRunningAppProcesses();
Iterator iter = list.iterator();
PackageManager pm = this.getPackageManager();
while(iter.hasNext()) {
ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(iter.next());
try {
CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
Log.w("APPS", c.toString());
}catch(Exception e) { }
}catch(Exception e) { }
}
Thanks
Process can contain running components from several packages, see field pkgList in RunningAppProcessInfo class.