1

Meaning a list of all the applications that are currently open. I know you have to use Usage Stats but don't know how. All the SO answers including very recent ones are about using the ActivityManager class even though that only works on API 20 (Kitkat Watch) and lower.

Someone tried asking the same question and also pointed out that ActivityManager doesn't work and got downvoted then a mod closed the question and linked to an answer that uses, yes you guessed it, the ActivityManager class: How to get list of all running apps programmatically

purchaseTest
  • 524
  • 3
  • 15
  • In the question you linked there is a comment to another question that has examples on how to use `Usage Stats Service` https://stackoverflow.com/questions/30619349/android-5-1-1-and-above-getrunningappprocesses-returns-my-application-packag – tyczj Apr 20 '21 at 16:15
  • I saw that. In the first answer the person who wrote it says it doesn't work on Android N or higher. And the second answer is about how to get the current foreground task. – purchaseTest Apr 20 '21 at 16:18
  • _"The person who wrote it says it doesn't work on Android N or higher"_. I don't see it saying that. It says: _"To get a list of running processes on Android Nougat you will need to use UsageStatsManager or have root access"_. As for the second answer only showing the current foreground task; it applies extra filtering on the data it gets from the `UsageStatsManager`. – Michael Apr 20 '21 at 16:28
  • I read the github page, he/she says their method does not work on Android N and that it's no longer being updated. That was their last update. – purchaseTest Apr 20 '21 at 16:29
  • The library is not using `UsageStatsManager` as far as I can tell. – Michael Apr 20 '21 at 16:33
  • You mentioned the second answer, does using `queryUsageStats` return only the apps that are still opened (not swiped up from the list)? – purchaseTest Apr 20 '21 at 16:41
  • I checked what `queryUsageStats` does and it returns basically all the apps installed on the device, not just the running ones. Yet strangely many answers on SO seem to think it's the solution. I'm curious if people know what "recent apps" or "running apps" actually means. – purchaseTest Apr 21 '21 at 10:15

0 Answers0