问题
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