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. Google blocking phones with specific firmware from the market?

Version 1.5 will require apps uploaded to market to specify the minVersion
flag in the Android manifest, so the market can filter and target the right

The filtering might not have been turned on yet, so the new firmwares might
be inadvertently locked for now.

take care,
Muthu Ramadoss. - Android Consulting.


2. Exception happened in MediaRecorder

The Cupcake code assumes you have an OpenMAX H.263 hardware encoder.


3. Is there a Castor for Android?

4. Android Layout

5. How to get word on touch point

6. question on tutorial

7. How to write a file with directory ?