0

There are a few questions about how to receive the list of the recently used apps (either with the UsageStatsManager or with the ActivityManager prior to lollipop). Those all work fine and I use them successfully.

E.g. this explains how to get this list on an android lollipop and higher: How to get list of recent apps with Android API 21 Lollipop?

Problem

The problem is that the above solution (and similar ones) doesn't return the exact same list like the one which is shown when pressing the android recent apps button. Above solution also contains views like the android recent app screen itself.

Does anyone have an idea how to filter out all packages of apps that are no real apps or alternatively to get the exact same list of recent apps as the android recent apps button?

Currently, I manually filter out following packages, but there are probably more and this is not beautiful nor safe:

val systemPackages = arrayOf(
        "com.android.systemui",        // recent apps screen - Samsung S9 with oreo
        "com.sec.android.app.launcher" // recent apps screen - Samsung S9 with pie
)
Samir
  • 3,139
  • 2
  • 17
  • 24
prom85
  • 16,896
  • 17
  • 122
  • 242
  • You can filter System Apps by checking flag `ApplicationInfo.FLAG_SYSTEM` . If this is what you want . – ADM Feb 05 '19 at 10:21
  • I will check how this flag behaves. I want to exclude the recent apps screen, overlays, chat heads and whatever is ignored by the system's recent apps screen as well. But system setting screens e.g. should not be ignored (which I think will be marked as system app by the flag you suggest as far as I know) – prom85 Feb 05 '19 at 10:24
  • Yeah you are right . Since there are lots of custom ROM available so you can not depend on manually filtering by package name . I though this flag will narrow it down . – ADM Feb 05 '19 at 10:27

0 Answers0