PackageManager pm = this.getPackageManager();
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> runningAppProcesses = am.getRunningAppProcesses();
for(RunningAppProcessInfo process : runningAppProcesses) {
try {
ApplicationInfo ai = pm.getApplicationInfo(process.processName, PackageManager.GET_META_DATA);
Log.d(TAG, applicationInfo.name + "");
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
process.processName returns a valid package name but applicationInfo.name is always null.