skip to Main Content

I want to know from where my app is installed (who installed my app).

I need to use getInstallerPackageName(). And This method need to android.permission.INSTALL_PACKAGES permission. But this permission is not grant by the system.

this is a image
Returns null in all above methods.

  1. What way do you suggest to solve the problem?

  2. What other way do you suggest for this?

Thanks.

2

Answers


  1. I wouldn’t recommend using this permission:
    it probably will result in your app getting removed from google play store

    You should be using REQUEST_INSTALL_PACKAGES. The INSTALL_PACKAGES permission is not allowed to be used by third party apps according to the documentation: https://developer.android.com/reference/android/Manifest.permission.html#INSTALL_PACKAGES

    See also: https://android-developers.googleblog.com/2017/08/making-it-safer-to-get-apps-on-android-o.html?m=1

    update (src):

    Google Play restricts the use of high risk or sensitive permissions, including the REQUEST_INSTALL_PACKAGES permission, which allows an application to request installing packages. Apps targeting API level 26 or newer must hold this permission in order to use Intent.ACTION_INSTALL_PACKAGE or the PackageInstaller API.

    Login or Signup to reply.
  2. You can use PackageManager’s getInstallerPackageName() API without the need for INSTALL_PACKAGES. The android docs suggest that it is deprecated since API level 30 but:

    • android docs suggest Package Manager’s getInstallSourceInfo instead, and the installSourceInfo's getOriginatingPackageName() to get the desired info. However, only getOriginatingPackageName() needs INSTALL_PACKAGES.
    • getOriginatingPackageName() is only available on Android R and above, so I guess Google may close one eye to the usage of the deprecated getInstallerPackage() for a while. And for that, you don’t need the INSTALL_PACKAGES permission.
    • practical testing/usage in apps finds that getInstallerPackageName() still works as desired, and without the INSTALL_PACKAGES permission.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search