Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get a list of recently launched apps in android

 
shruthi Swamy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Long Press of homekey gives a list of recently launched applications.
I am trying to develop a app based on this.

I came to abt these API's:
ActivityManager.RecentTaskInfo Information you can retrieve about tasks that the user has most recently started or visited.
ActivityManager.RunningServiceInfo Information you can retrieve about a particular Service that is currently running in the system.
ActivityManager.RunningTaskInfo Information you can retrieve about a particular task that is currently "running" in the system.


But my question is:
ActivityManager am = (ActivityManager)context.getSystemService(Context. ACTIVITY_SERVICE);
List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(MAX_RECENT_TASKS, 0);


After making these calls, how to iterator the List(or recentTasks list) ..so that we can get a list of apps.


Thanks,
Shruthi
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shruthi shruthi", please check your private messages for an important administrative matter.
 
shruthi Swamy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am developing application which displays the recently launched
application. I am able to get the list of apps using
ActivityManager.RecentTaskInfo.

Now i need to keep track of "how many times an application is
launched" and "also execution time of an application"?

In spare parts example, this is done. To achieve this they have used:
PkgUsageStats
public PkgUsageStats(String pkgName, int count, long time) {
packageName = pkgName;
launchCount = count;
usageTime = time;
}


But in the latest android SDK , PkgUsageStats is been replaced by
PackageStats
and it has only:
public PackageStats(PackageStats pStats) {
packageName = pStats.packageName
codeSize = pStats.codeSize;
dataSize = pStats.dataSize;
cacheSize = pStats.cacheSize;
}

So is there any other way to get the "launchCount"?
What is the alternative for this function?


Regards,
Shruthi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic