Retrieving PackName from RecentTaskInfo

by Mark Hansen » Sat, 10 Apr 2010 01:42:38 GMT

Sponsored Links
 I'm  trying to the the application and icons for Recent Tasks, but I
can't seem to get the appInfo using the RecentTaskInfo.  The
getApplicationInfo call is what is failing due to the getPackageName()
returning null.

 ActivityManager manager =
 List<RecentTaskInfo> tasks = manager.getRecentTasks(50, 1);
        for (int counter = 0; counter < tasks.size(); counter++)
                RecentTaskInfo task =  tasks.get(counter);
                PackageManager pm = this.getPackageManager();

try {

                        ApplicationInfo appInfo  =
                       String applicationName =
                       Drawable icon = appInfo.loadIcon(pm);

I've also tried:

ApplicationInfo appInfo  =

In which getPackage() is returning null.. maybe I'm going about this
the wrong way and was hoping for some tips?


Retrieving PackName from RecentTaskInfo

by Mark Murphy » Sat, 10 Apr 2010 01:54:38 GMT


It may be there's a way to get things to work going down the path you're

Personally, I'd look at the source to RecentApplicationsDialog and see
how they do it. You can find this in Google Code Search by searching on:

package:android recentapplicationsdialog

The reloadButtons() method uses getRecentTasks(). They create an Intent
for each task, use resolveActivity() on PackageManager to get the
ResolveInfo on the activity, then use loadLabel()/loadIcon() to get the
display stuff.

Mark Murphy (a Commons Guy)  | 

Android App Developer Books: 


Sponsored Links

Other Threads

1. How to catch a link clicked in SMS or Email application?


In my application user can send a link to his/her friend via SMS or Email. I
want to do that if my appliation is already installed receiver user's phone,
how to open or send a parameter to the application to open a specific
activity. Is it possible to catch  when browsers starts and get the opening
url to parse or sms intent content click. Is there any way?

For example,

When i receive an email which iclude a google maps link it asks me open with
internet or google maps. that's the exactly i want to do that ... thankssss

Nesim TUN
Senior Software Developer of Distributed Applications


2. Paging Yudha Y H S

hi bro
pantau nga ?
gue hilang no HP dikau......
japri yah
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


3. Shared Preference Change Listener in a Widget

4. [WTA] overclock droid x

5. "down arrow" circle icon view?

6. Bluetooth pairing and source hide problem.

7. custom attributes in library projects