确保从Play-Store安装Android应用程序

时间:2013-07-31 11:46:05

标签: android google-analytics google-play android-install-apk campaign-monitor

我最近发现了BlackMarket应用程序,这是一个谷歌Play-Store应用程序,这些人从Play-Store获取付费应用程序,让他们的用户下载并免费使用它。

作为一个计划为我的应用程序收费的开发商,这让我感到困扰,我想确保我的应用程序是通过Play-Store或我批准的任何商店安装的。

我想验证此类事情的唯一方法是通过广告系列跟踪,但自从谷歌分析v2以来,广告系列的跟踪工作就在Jar的接收器中完成。

还有其他方法可以确定我的应用安装的来源吗? 有没有办法拦截广告系列跟踪数据?

感谢。

3 个答案:

答案 0 :(得分:6)

点击此链接here。然后

PackageManager pm = getPackageManager();
String installationSource = pm.getInstallerPackageName(getPackageName());

从标记处安装后,installationSource将返回com.google.android%com.android.vending%之类的内容。但是这会发生变化,你必须在发生变化时保持(支持)它 - 否则它将从其他应用程序(不受欢迎的应用程序:)返回null(来自调试器)或其他一些包名称。)

答案 1 :(得分:0)

我发现知道应用是否来自Play商店的最佳方式是g00dy建议:使用安装程序包名称。

String packageName = appContext.getPackageName();
String installerPackage = appContext.getPackageManager().getInstallerPackageName(packageName);

如果应用程序已在Play商店中下载(即使应用程序是通过PC购买的),installerPackage也应为“com.vending.google”。

答案 2 :(得分:0)

我找到了这个 http://developer.android.com/google/play/licensing/licensing-reference.html#lvl-summary

public boolean allowAccess() {
    long ts = System.currentTimeMillis();
    if (mLastResponse == LicenseResponse.LICENSED) {
        // Check if the LICENSED response occurred within the validity timeout.
        if (ts <= mValidityTimestamp) {
            // Cached LICENSED response is still valid.
            return true;
        }
    } else if (mLastResponse == LicenseResponse.RETRY &&
                ts < mLastResponseTime + MILLIS_PER_MINUTE) {
        // Only allow access if we are within the retry period or we haven't used up our
        // max retries.
        return (ts <= mRetryUntil || mRetryCount <= mMaxRetries);
    }
    return false;
}