getInstallerPackageName returns null

后端 未结 3 538
长发绾君心
长发绾君心 2020-12-06 19:41

In my Android app I wanted to check the source of app installation. I looked at the Android documentation and found the following API as part of the PackageManager class:

3条回答
  •  遥遥无期
    2020-12-06 20:19

    if you want to test this the way is to store the apk on the device by using the

    adb push 'test.apk' '/sdcard/Download'

    then go to the adb shell by typing in 'adb shell' and hitting enter in the terminal then install using the following command

    pm install -i 'installernameyouwant' /sdcard/Download/test.apk

    when installing the app in above method the call to getInstallerPackageName() returns the installer name you gave in the above command

    credits to @mattmook for the "pm install" command.

提交回复
热议问题