【问题标题】:how launch amazon prime video app from within my android app using intent如何使用意图从我的 android 应用程序中启动 amazon prime video 应用程序
【发布时间】:2018-09-17 12:38:42
【问题描述】:

我正在创建一个 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();
            }
        }

【问题讨论】:

  • 包是com.amazon.avod.thirdpartyclientcom.amazon.amazonvideo.livingroom 是电视应用程序。
  • 将包名称设置为“com.amazon.avod.thirdpartyclient”不会启动已安装的主要视频应用程序。它仍在浏览器中打开。
  • 请试试我的回答。

标签: android


【解决方案1】:

尝试使用以下意图

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

如果没有找到这个意图,那么你会得到一个异常。如果出现异常,则在 catch 块中打开 url。

【讨论】:

    猜你喜欢
    • 2019-07-22
    • 2021-12-12
    • 2012-01-26
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 2017-08-23
    • 1970-01-01
    相关资源
    最近更新 更多