如何使用意图从我的Android应用程序中启动Amazon Prime视频应用程序

时间:2018-09-17 12:38:43

标签: android

我正在创建一个Android应用,其中用户可以选择从我的应用中启动Amazon Prime应用。我无法找到Amazon Prime应用的软件包名称。这段代码仅在浏览器中打开Amazon Prime。

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();
            }
        }

1 个答案:

答案 0 :(得分:0)

尝试使用以下意图

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

如果未找到此意图,则将获得异常。如果出现异常,请在catch块中打开url。