确定android Play商店

时间:2014-02-19 05:35:49

标签: android google-play amazon-appstore

我在我的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);
    }

但我无法测试它。因为我总是从本地构建中获取null。有没有办法测试它是否有效。

1 个答案:

答案 0 :(得分:0)

谷歌允许您设置alpha和beta测试组:http://developer.android.com/distribute/googleplay/developer-console.html#alpha-beta

您的想法是以“alpha”状态发布应用,并指定具有访问权限的Google(+)群组。然后他们可以通过Play商店下载,但普通用户不会看到它。