There are lots of reasons to link to the listing for an Android app from within the app; several of those reasons include linking to a paid upgrade, linking to all of your other apps, or even encouraging users to rate your app. Sometimes you need a supporting app, and the user must download and install it to make full use of your app — for example, a barcode reader. This becomes more complicated if you deploy your app to other Android app markets beyond Google Play.
Many app stores have their own mechanism to link to their apps, and sometimes they enforce that all links should be to their store. For example, the Amazon Appstore quality assurance will reject apps that link back to Google Play. If you’re not familiar with the rules, read about passing quality assurance for curated app stores.
Mutually exclusive linking
The main problem is that many stores have a mutually exclusive system for linking to their apps. With a few exceptions, most app market browsers won’t hijack the Google Play URI (Universal Resource Indicator — the address to go to) scheme, which is in the format “market://details?id=your.package.name.” Problems arise when the appropriate market browser app is not installed — these custom URIs won’t work.
Some custom URI schemes that link directly to their respective market browser apps are:
Beyond that, there are http-based URIs for many stores. However, while some market browser apps will hijack links to their web pages, others won’t. It’s not just that the URI differs between stores — some are missing features such as “all apps by developer X.” Some, such as the Nook Store, use an entirely different mechanism with a custom intent, requiring a bit of extra code. All this makes it difficult to release a single APK for an app and have it correctly link to the app store it came from.
While some have advocated detecting which app stores are installed on the device, this can be problematic — what if a user has installed the app from the Amazon Appstore, but also has Google Play on the device? Which market would this mechanism choose?
Making it all work together
I put a lot of effort over the last few years into investigating other Android app markets beyond Google Play. I have released my apps onto many markets, and when I update them, I have quite a few places to roll that update out to. I want the linking mechanisms to be rock solid and not require any attention in any of my apps.
Since it took a while to get the linking right for my main app stores, I decided to share the code — check out the Android Market Manager library (available for free, as in Apache licensed). This library takes care of sending the user to the right app store. The syntax is as simple as:
In the above example, everything is a project constant except for the activity and the market selection variable. See the test project for a complete example of using this library. You can use it as I do, with a static variable baked into each flavor of APK for each app store; or, you can implement dynamic logic to decide which app store to choose. The code doesn’t care how you figure out which app store to use.
Even if you don’t want to use the library, take a look at the documentation of the different URI types for these app markets. It’s rare to have information on that many app markets in one place — each app market usually acts as if it’s the only one out there.
Now that you know how to link to different app stores, you’re ready to release your app to other Android markets and expand your reach.