After the user has enabled Usage Access you seem to require the new QUERY_ALL_PACKAGES
permission in Android 11+ to access a package’s name and icon with the following code:
String appName = packageManager.getApplicationLabel( packageManager.getApplicationInfo(packageName,0) );
Drawable appIcon = packageManager.getApplicationIcon(packageName);
Otherwise I would get a PackageManager.NameNotFoundException
for either lines of code which obviously means I don’t have access to the friendly app name and icon.
Is there another way to achieve this without the permission? I can’t find any other way other than code prior to Android 11.
I maintain an app that also features a screen time functionality but Google has refused to approve the inclusion of this “sensitive permission” in my update despite it being a core functionality of my app, claiming there are other ways to achieve this but also refusing to elaborate.
Keeping a whitelist of apps using isn’t really a viable way of accessing the names and icons of the apps used.