1

I'm creating an android app where in user have the option to launch amazon prime app from within my app. i am unable to find package name for amazon prime app. This code only open amazon prime in browser.

public void onClick(View v) {
   String urlAmazonPrime = "https://www.primevideo.com";
   Intent intentAmazonPrime = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAmazonPrime));
            intentAmazonPrime.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intentAmazonPrime.setPackage("com.amazon.amazonvideo.livingroom");
    try {
                response = "success";
                startActivity(intentAmazonPrime);
            } catch (ActivityNotFoundException ex) {
                // Chrome browser presumably not installed so allow user to choose instead
                intentAmazonPrime.setPackage(null);
                startActivity(intentAmazonPrime);
                response = "notfound";
                Toast.makeText(MainActivity.this, "Amazon Prime Not Found", Toast.LENGTH_SHORT).show();
            }
        }
Rohit5k2
  • 17,948
  • 8
  • 45
  • 57
Kiran
  • 11
  • 2

1 Answers1

2

Try using the following intent

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.amazon.avod.thirdpartyclient");
startActivity( launchIntent );

If this intent is not found, then you would get an exception. If the exception arises then open the url in catch block.

Rohit5k2
  • 17,948
  • 8
  • 45
  • 57