android.permission.INSTALL_PACKAGES permission in android-studio

Viewed 89

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.

1 Answers

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.

Related