Set “installer” package value as returned in getInstallerPackageName()

我只是一个虾纸丫 提交于 2019-12-07 05:35:29

问题


I have an Android app that uses a WebView to enable users to install applications. Historically, applications installed from Android Market will have the installer value set to "com.google.android.feedback". With Google Play, this value is now "com.android.vending".

This value can be obtained by:

PackageManager pm = context.getPackageManager();
String installer = pm.getInstallerPackageName(pname);

The apps installed by my WebView have an installer value set to null. How can I set my own installer value, such as com.mydomain.store?


回答1:


You could try using setInstallerPackageName.

But you would have to set the installer package name after the package is installed, and the installer package name would have to be empty/null.




回答2:


While this doesn't strictly answer the question to do this programmatically, it's also possible to set the vendor package through adb without needing it to be signed with the same key.

There's a complete explanation here, but it boils down to:

The following adb trick sets the install vendor of a debug app:

adb push app.apk /sdcard/app.apk
adb shell pm install -i "com.android.vending" -r /sdcard/app.apk
adb shell rm /sdcard/app.apk

To confirm that this has worked, list the packages using the Package Manager:

adb shell pm list packages -i [packagename]

If all has gone well, you should see this output:

package:[packagename]  installer=com.android.vending


来源:https://stackoverflow.com/questions/9146820/set-installer-package-value-as-returned-in-getinstallerpackagename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!