In my app, I have a 'rate me' button. It follows the usual path - user clicks in, it starts an intent and opens the app's listing on the Play Store. All well and good. Now I wish to try to distribute my app via different app stores (Amazon for example), so obviously, if the user hits the 'rate me' button I don't want it to take the user to the Google Play Store but to whatever store they got it from.

APK For each store

This is possible, true, but I think it would be a complete nightmare to manage (like creating a new APK for each store every time I issue a new update.

So I'm looking for something like this pseudo code:

if(rate-me button pressed){

    if (from Google Play Store){
        Go to Google Play Store
    else if (from Amazon Store){
        Go to Amazon Store

And so on.......

I'm guessing there is a way (that some apps must surely use) but I have no idea how to go about it.

  • 1
    \$\begingroup\$ So... why not create the same app, but decide based on some resource? Would not adding open_store.txt and switch based on the contents work? \$\endgroup\$
    – wondra
    Aug 31, 2014 at 23:19
  • \$\begingroup\$ Hi @wondra, I'm not sure I understand what you mean? Do you mean create a text file and then write to it when the app is installed (with a per-determined value, let's say 1 for Google Play, 2 for Amazon etc.) Then query that file when the user hits the rate-me button? If that's what you mean, that's good but the question would still be the same, how would I programmatically determine which store the app was installed from so I could write to the file in the first place? I may have misunderstood you though!! \$\endgroup\$ Aug 31, 2014 at 23:22
  • 5
    \$\begingroup\$ Just deploy 3 versions of your app with conditional compilation; each with a different path. The variable / code path can change depending on the compiled variable. \$\endgroup\$ Sep 1, 2014 at 1:20
  • \$\begingroup\$ @VaughanHilts could you elaborate please? Or maybe post full idea as an answer? Thanks! \$\endgroup\$ Sep 1, 2014 at 2:10
  • 1
    \$\begingroup\$ I was about to say exactly the same as Vaughan Hilts said. Make different versions of the app for different stores. \$\endgroup\$ Sep 1, 2014 at 2:50

2 Answers 2


I'm going to assume you're writing in Java as you're writing for Android, but if you're not you can look up methods in your language of choice to get the same sort of result. Since Java has no built in support for conditional compilation, there's some pretty easy things you can do here; sometimes the low-tech solution is the best one.

Deploy a different app compiled from different code for each app store. It can be that simple. Just have a global string (or not, encapsulate it where the appropriate logic is) and simply assign it a value, compile, and deploy. It's that easy.

It can be a string, an enum value or integer. It doesn't really matter -- as long as each value is unique per app store. I'd suggest a quick strongly-typed enum with options like "Amazon", "GooglePlay", "XXXX", "ZZZZ", "YYYY". Write scripts to change this value or pass in compilation flags using 3rd party tools if you want this to be automated.

Automating it up

If you want to take this one step further, parse the option as resource file. Write scripts, one for each deployment. Have a file called "store.dat" and write the value of the store it's being deployed to the file when deployed, if you're under Linux or OSX it could be something as simple as

echo "Google" > resources/store/store.dat

Make one script to execute all of these scripts in lock step and you have a robust, automated solution.

  • \$\begingroup\$ Thanks for this @VaughanHilts, got a few questions, at the moment, I have a string value called 'Market' which contains the URL to the market, is this the kind of thing you mean, and just change it when I compile, so I would have a different APK for each market? \$\endgroup\$ Sep 1, 2014 at 18:45
  • \$\begingroup\$ Sure thing. :) You could do this in a variety of ways, the magic bullet is just making sure you can identify the install type. \$\endgroup\$ Sep 1, 2014 at 19:42
  • \$\begingroup\$ OK, so far so good @VaughanHilts, I get that part, what I'm still not clear on is this bit: "Write scripts to change this value or pass in compilation flags using 3rd party tools if you want this to be automated" - I'm just not clear on what is meant by this - if I manually change my market string, is there any need for this part as when I start my intent, I pass the market string to it anyway so it would open that market - thanks again, I hope you can explain in a bit more details so I understand correctly! :-) Cheers \$\endgroup\$ Sep 3, 2014 at 0:54
  • \$\begingroup\$ @user22241 Hi, there's no need to do that part unless you don't want to have to change the string by hand for each build. Writing scripts would just make the changing and deployment automatic. We can continue in chat if you have more questions. \$\endgroup\$ Sep 3, 2014 at 1:56
  • \$\begingroup\$ Cool @VaughanHilts, I have a silly question, how does chat on this site work? I've never used it. Thanks! \$\endgroup\$ Sep 4, 2014 at 18:07

try this:

try {
    String packagename = context.getPackageName();
    final PackageManager pm = context.getPackageManager();
    PackageInfo pInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
    String installerPackagenName = pm.getInstallerPackageName(packageName);
        //Go to Amazon Store
    } else if (installerPackagenName.equalsIgnoreCase("com.android.vending")){
        //Go to Google Play Store
    } else {

} catch (PackageManager.NameNotFoundException e) {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .