Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect user to App Store in Android

It is known that we can send the intent as described in the following link and then it redirects user to Google Play.

Uri marketUri = Uri.parse("market://details?id=" + packageName);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);

But the problem is that all app store, especially Amazon App Store (in Kindle), can handle this intent as well?
I know that the following URI must redirect user to amazon app store:

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

But, I don't want to have two binaries, one for ordinary Android and the other for Amazon.

like image 974
Bear Avatar asked Jun 25 '12 09:06

Bear


1 Answers

There is no generic method, the thing to do here is set a bunch of flags in your code.

so you would have something like

boolean AMAZON_APK=true;
boolean ANDROID_APK =false;
....

Then you would set the appropriate values when you want to publish to amazon and when you want to publish to Android Play. In your code before launching the market you would check the flags with a bunch of if statements and launch the appropriate intent depending on what the particular market supports. This is not a huge deal since you only have to change a few variables.

if(AMAZON_APK)
  //launch amazon intent
if(ANDROID_APK)
  //launch android market intent
....

You can see a more complete example here. How can I do an Amazon App Store search using an Intent and filter it by developer name? also if some markets don't support anything like a market intent you can launch a link to a mobile website and point the user to your apps from there.

like image 101
mbwasi Avatar answered Nov 10 '22 10:11

mbwasi