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.
Returns null
in all above methods.
-
What way do you suggest to solve the problem?
-
What other way do you suggest for this?
Thanks.
2
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):
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:installSourceInfo's
getOriginatingPackageName()
to get the desired info. However, onlygetOriginatingPackageName()
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 deprecatedgetInstallerPackage()
for a while. And for that, you don’t need the INSTALL_PACKAGES permission.getInstallerPackageName()
still works as desired, and without the INSTALL_PACKAGES permission.