0
我寫了下面的代碼在我的Android應用程序,以確定哪些Play商店是從downlaoded:確定的Android Play商店
public enum AppStore {
GOOGLE("com.android.vending", "market://details?id="),
AMAZON("com.amazon.venezia", "amzn://apps/android?p=");
private String packageName;
private String marketUrl;
private AppStore(String pName, String url) {
this.packageName = pName;
this.marketUrl = url;
}
public String getPackageName() {
return this.packageName;
}
public String getMarketUrl() {
return this.marketUrl;
}
public static AppStore getAppStore(String packageName) {
if(GOOGLE.packageName.equalsIgnoreCase(packageName)) {
return GOOGLE;
} else if(AMAZON.packageName.equalsIgnoreCase(packageName)) {
return AMAZON;
}
return null;
}
};
public static AppStore getAppStore(Context ctx) {
String packageName = ctx.getPackageName();
PackageManager pacman = ctx.getPackageManager();
String installer = pacman.getInstallerPackageName(packageName);
return AppStore.getAppStore(installer);
}
但我不能對它進行測試。因爲我總是從我的本地構建中獲得空值。有沒有什麼方法可以測試它是否工作。