I need some code to get an object or an arraylist that contains all the names of those applications that currently are in the recents stack of android. Maybe android doesn't permit to do that (for security reasons) so even code which needs root permissions is ok for me.
How to programmatically get the names of apps that currently are in the recents stack of android?
2.2k views Asked by Emanuele C. At
1
Solution 1:
Use
getRunningAppProcesses
, which will return a list ofRunningAppProcessInfo
objects that will give you some data about each running app. One of the pieces of information you can retrieve about the app is itsimportance
, which can have a valueIMPORTANCE_FOREGROUND
which indicates that the process is the currently active.Some guide For you as well.
IMPORTANCE_FOREGROUND
RunningAppProcessInfo
Solution 2: I was also developing an application for locking the apps. It seems you need to ask user to provide this setting. I used this activity to check which app is in foreground but I Guess it can work according to you also.
On my mobile It's written
UsageStatsManager
has some useful methods that can satisfy your need.i think you need to ask this from your user and if the user agrees. you can use gain access to the recent Apps.