How to know if an app has been downloaded from Google Play or Amazon?

前端 未结 2 1612
一整个雨季
一整个雨季 2021-02-01 07:18

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

I have deployed an a

2条回答
  •  死守一世寂寞
    2021-02-01 08:00

    In 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" 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.

    Via ADB:

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

    Example:

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

提交回复
热议问题