Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PackageManager.getInstallerPackageName() tell me that my app was installed from Amazon app store?

Tags:

I plan on publishing my app on Amazon app store as well as Google Play, and have some things in my app that need to behave slightly different depending on whether the app was installed from Amazon app store or not. If I understood the PackageManager.getInstallerPackageName(String packageName) method correctly, it tells me the name of the application that installed my app. Right? If so, does anyone know what the value returned by this method would be if my app was installed from Amazon app store? If not, does anyone know any other methods I can use to determine whether my app was installed from the Amazon app store?

Note: I am aware of other questions on Stack Overflow which have been answered alluding to the usage of PackageManager.getInstallerPackageName(String packageName) to determine the name of the application that installed my app. However, searching Stack Overflow and elsewhere, I have not been able to determine what the value returned by PackageManager.getInstallerPackageName(String packageName) would be in case the app was installed from the Amazon app store.

like image 948
Adil Hussain Avatar asked Nov 08 '12 13:11

Adil Hussain


1 Answers

Since samsung has not implemented the PackageManager.getInstallerPackageName(), it still returns null. So use the PackageManager.getInstalledPackages() to get all the packages and search for the samsungapp packagename "com.sec.android.app.samsungapps".

Stores:

null - developer com.android.vending - google play com.amazon.venezia - amazon app com.sec.android.app.samsungapps - samsung app store 

Code:

// lets start with google play store link String link = "https://play.google.com/store/apps/details?id=com.hellothupten.capital2countryquiz";  //find out the installer for your app package name. String installer = getPackageManager().getInstallerPackageName(         "com.hellothupten.capital2countryquiz");  if (installer == null) {     List<PackageInfo> installedPackages = getPackageManager()             .getInstalledPackages(PackageManager.GET_ACTIVITIES);     for (PackageInfo p : installedPackages) {         if (p.packageName.contains("samsungapps")) {             // change to samsung app store link             link = "http://apps.samsung.com/mars/topApps/topAppsDetail.as?productId=000000840239";             break;         }     } } else if (installer.contains("amazon")) {     // change to amazon app store link     link = "amzn://apps/android?p=com.hellothupten.capital2countryquiz"; } else if (installer.contains("samsung")) {     // change to samsung app store link. This does not     // exist..but who knows samsung may implement     // getInstallerPackageName in future, I assume it will     // contain a word samsung in its package name.     link = "http://apps.samsung.com/mars/topApps/topAppsDetail.as?productId=000000840239";  } 

Use the link variable as the store link.

Update:

samsungapps://ProductDetail/com.sec.chaton 

Samsung: http://developer.samsung.com/android/technical-docs/Samsung-Apps-Deeplink-Guide

like image 65
Thupten Avatar answered Sep 17 '22 14:09

Thupten