4

I have seen answers regarding Amazon Appstore from iPhone but not from Android. I'm trying to make a button that will open the Amazon Appstore (for android) on my app's page.

Here is how it's done for Google Play:

final String appPackageName = context.getPackageName();

try {
    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)); 
} catch (android.content.ActivityNotFoundException e) {
    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName));
}

How should I replace the Strings so that it works "the same" for Amaozn AppStore?

UFC Insider
  • 708
  • 4
  • 17

2 Answers2

6

The Amazon app store URI is

amzn://apps/android?

Directing to a particular app would look like

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

Source: Linking To the Amazon Appstore for Android

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
1

Look into WebViews. It does exactly what you want, you can open a page in your own app. Simply define a webview in the xml, and use the java to display the page.

How to do it without webview:

(From docs)

By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won't need to interact with the web page beyond reading it, and the web page won't need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView. For example:

Uri uri = Uri.parse("http://www.example.com");
 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 startActivity(intent);

With webview:

 webview.loadUrl("http://slashdot.org/");

 // OR, you can also load from an HTML string:
 String summary = "<html><body>You scored <b>192</b> points.</body></html>";
 webview.loadData(summary, "text/html", null);

Let me know if this works by commenting.

Ruchir Baronia
  • 6,857
  • 4
  • 45
  • 75
  • I would like to use the Intent option. Can you help me with the strings? – UFC Insider Mar 05 '16 at 19:03
  • 1
    Take a look at the duplicate in the comment. OP wants to use intents and needs to know the URI string of the Amazon App Store application in Android – OneCricketeer Mar 05 '16 at 19:12
  • 1
    @UFCInsider Take a look at `cricket_007`'s answer to see what string you need to put. Then, use the syntax described in my answer to actually make it work – Ruchir Baronia Mar 05 '16 at 19:20
  • 1
    @cricket_007 Oh, okay. That wasn't too clear to me. Hopefully the OP can still use this answer with your answer to finish his/her task. I have upvoted your answer :) – Ruchir Baronia Mar 05 '16 at 19:20
  • Thank you guys! The answer by @cricket_007 was exactly what I wanted! – UFC Insider Mar 05 '16 at 19:26