如何知道,如果一个应用程序已经从谷歌播放或亚马逊下载?亚马逊、应用程序

由网友(.﹎改鋽﹏)分享简介:有没有办法知道,如果一个应用程序已经从亚马逊或谷歌下载播放?我的应用程序,当然本身,在含义。Is there any way to know if an application has been downloaded from Amazon or Google Play? I meant within the app...

有没有办法知道,如果一个应用程序已经从亚马逊或谷歌下载播放?我的应用程序,当然本身,在含义。

Is there any way to know if an application has been downloaded from Amazon or Google Play? I meant within the app itself, of course.

我已经部署了一个应用程序到两个站点,我宁愿想知道从那里得到了客户的应用程序中下载了它。我知道我可以部署不同的应用程序的每个服务,但这种广告能够避免,如果有某种方式一些维护工作,以解决它只是与应用程序内的条件使用相同的封装。

I have deployed an app to both sites and I rather like to know from where the customer has downloaded it within the application. I know I can deploy different applications to each service, but this ads some maintenance work that could be avoided if there were some manner to solve it just with a conditional within the app using the same package.

推荐答案

在code:

final PackageManager packageManager = getPackageManager();

try {
    final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
    if ("com.android.vending".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) {
        // App was installed by Play Store
    }
} catch (final NameNotFoundException e) {
    e.printStackTrace();
}

com.android.vending告诉你它从谷歌来了Play商店。我不知道亚马逊的Appstore是什么,但它应该很容易测试使用上述code。

"com.android.vending" tells you it came from the Google Play Store. I'm not sure what the Amazon Appstore is, but it should be easy to test using the above code.

通过ADB:

adb shell pm dump "PACKAGE_NAME" | grep "vending"

例:的

adb shell pm dump "com.android.chrome" | grep "vending"

installerPackageName=com.android.vending
阅读全文

相关推荐

最新文章