I have searched the stackoverflow for this question and found : Android, Detect when other apps are launched and Reliable way to detect application launch from home / desktop? , which kind of answers my question but it's still not enough.
What I want to do I want to create a widget/app that shows the user of the device a list of recent apps and a list of most used apps.
Problem How can I have accurate data about the apps in order to build a list of most used apps.
Base information
Some solutions
The recent apps can be found via ActityManager, getRecentApps method, so now problem there.
I have searched the web for this and already found the following solutions:
Anything else I have missed?
Thanks in advance, Tiago Costa
Activities will very often need to support the CATEGORY_DEFAULT so that they can be found by Context. startActivity(). So, CATEGORY_DEFAULT can appear number of times. Android does not grab whichever one appears first in the manifest but it starts with activity having CATEGORY_LAUNCHER.
Launch mode is an instruction for Android OS which specifies how the activity should be launched. It instructs how any new activity should be associated with the current task.
In Android 4.0 to 4.2, hold the "Home" button or press the "Recently Used Apps" button to view the list of running apps. To close any of the apps, swipe it to the left or to the right. In older Android versions, open the Settings menu, tap "Applications," tap "Manage Applications" and then tap the "Running" tab.
Android default recent apps dialog implementation is best reference for you, look here..check reloadButtons()
final ActivityManager am = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RecentTaskInfo> recentTasks =
am.getRecentTasks(MAX_RECENT_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
You can try in similar way..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With