i'm trying to making a app that shows running app icon in custom listview, and switch to corresponding app when click icon. i think i should use "ActivityManager.RunningTaskinfo", "PackageManager" and "intent" to make it so i'm trying.. but i got error on my code.. i got error on "topActivity" How can i fix this error? and how to show "rtid" which is the icon that i got from activitymanager and packagemanager in the custom listview using such as "Drawable[] images = new Drawable[packs.size()];"
ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(100);
ApplicationInfo appInfo = getPackageManager().getApplicationInfo(tasks.topActivity.getPackageName(), 0);
Drawable rtid = getPackageManager().getApplicationIcon(appInfo);