Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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 adds 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.

like image 703
Fran Marzoa Avatar asked Jun 17 '12 14:06

Fran Marzoa


People also ask

Does Amazon Appstore have same apps as Google Play?

What Is the Amazon App Store? Simply put, the Amazon App Store is the app store that is available on all Amazon Fire devices, including the Kindle Fire and the Fire Stick. It essentially serves the same purpose as the Google Play Store and has Android apps for these devices.

How do you check if an app has been downloaded?

By default, Android users get most of their apps from Google Play Store. You can view the app download history in Google Play Store from the Installed or Library sections of the Store. The Installed section shows you all the apps currently installed on your Android device.

How do you tell if an app has been downloaded on Android?

You can see all the apps you've ever downloaded on your Android phone by opening the "My apps & games" section in your Google Play Store. The apps you've downloaded are divided into two sections: "Installed" (all the apps currently installed on your phone) and "Library" (all the apps that aren't currently installed).


2 Answers

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
like image 130
Scott Kennedy Avatar answered Oct 21 '22 14:10

Scott Kennedy


While in most cases you can get the store name by including a check similar to this:

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
    }  else if ("com.amazon.venezia".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) {
        // App was installed by Amazon Appstore
    } else {
        // App was installed from somewhere else
    }
} catch (final NameNotFoundException e) {
    e.printStackTrace();
}

"com.android.vending" is Google Play Store and
"com.amazon.venezia" is the Amazon Appstore, and
null when it was sideloaded

The results could be unreliable however, as for example during beta testing a store might not set this value, and besides it's possible to sideload your app specifying the installer's package name that could be interpreted as a store name:

adb install -i <INSTALLER_PACKAGE_NAME> <PATH_TO_YOUR_APK>

You might want to consider having different application IDs for different stores, for example "com.example.yourapp" for Google and "com.example.yourapp.amazon" for Amazon -- you can easily set those in your Gradle script.

like image 42
Levon Avatar answered Oct 21 '22 12:10

Levon