2

When I run my app on certain physical devices, the Android PackageManager seems to only detect system apps. For example, I have the Facebook app installed, but calling PackageManager.getPackageInfo on com.facebook.katana results in a NameNotFoundException. getInstalledPackages(PackageManager.GET_META_DATA) returns a list of what appears to be system apps only (i.e. the package name starts with com.android, com.samsung, etc). Again, this only seems to occur on physical devices that I have tested. On my emulator, everything works as expected (i.e. all apps are detected).

Any ideas why this is happening?

syhark
  • 35
  • 5

1 Answers1

3

This can happen on Android 11 devices due to new policies on package visibility https://developer.android.com/about/versions/11/privacy/package-visibility

you should declare the package names that want to search in execution time in your apps manifest

<manifest>
    ...
    <queries>
        <package android:name="package.name.to.search"/>
    </queries>
</manifest>
oadussang
  • 31
  • 3
  • Do I put this on the app I'm searching for or on the app I'm searching from? Edit: ignore this, it has to be on the app you are searching from. – casolorz Jul 16 '22 at 19:39