Detect if an Android app was downloaded from Google Play vs Amazon vs Other

前端 未结 2 1340
心在旅途
心在旅途 2021-01-31 10:37

I know this is probably a longshot, but is there any way to detect programatically whether an app was hosted on the Amazon apps store vs on Google Play? I would like to link to

2条回答
  •  耶瑟儿~
    2021-01-31 11:25

    As of just recently, the Amazon Appstore returns sane values for PackageManager.getInstallerPackageName()

    PackageManager pm = context.getPackageManager();
    String installerPackageName = pm.getInstallerPackageName(context.getPackageName());
    
    if ("com.android.vending".equals(installerPackageName)) {
        //do google things
    } else if ("com.amazon.venezia".equals(installerPackageName)) {
        //do amazon things
    }
    

    See here: https://forums.developer.amazon.com/forums/thread.jspa?threadID=680

    Examples for rate this app links:

    Google Play-

    market://details?id=PACKAGANAME

    Amazon Store

    http://www.amazon.com/gp/mas/dl/android?p=PACKAGENAME

    or

    amzn://apps/android?p=com.amazon.mp3

提交回复
热议问题