【问题标题】:Intent.createChooser for ACTION_VIEW shows default browser onlyACTION_VIEW 的 Intent.createChooser 仅显示默认浏览器
【发布时间】:2017-08-07 04:05:01
【问题描述】:

我正在尝试使用 Intent.createChooser 显示一个应用选择器对话框,该对话框将列出用户手机中所有可用的网络浏览器。 我正在使用下面的代码:

        Intent browserIntent = new Intent(Intent.ACTION_VIEW);
        browserIntent.setData(Uri.parse(category));
        // Create and start the chooser
        Intent chooser = Intent.createChooser(browserIntent, "Open with...");

        pIntent = PendingIntent.getActivity(helperMethodContext, 0, chooser, PendingIntent.FLAG_UPDATE_CURRENT);

        Log.d("HelperMethods: ", "video chat url: " + category);  

我在 android 6 上对此进行测试。我的手机有 3 个浏览器,默认浏览器、chrome 和 firefox。当我运行它并单击链接(通知)时,应用程序选择器对话框打开,但仅显示默认浏览器。它不显示 chrome 或 firefox。

我已检查手机中的默认应用程序设置,但没有默认浏览器。当我点击默认浏览器时,它会打开一个应用选择器对话框,其中显示了我在手机上安装的所有浏览器应用。

谁能告诉我哪里出错了。

【问题讨论】:

  • @JaydeepPatel 我不想在单击链接时打开默认浏览器。我想显示包含所有已安装浏览器列表的应用选择器对话框
  • 这可能对你有帮助:stackoverflow.com/questions/2201917/…
  • @JaydeepPatel 我没有在默认应用设置中设置默认浏览器。请完整阅读问题。

标签: android android-intent


【解决方案1】:

您拥有哪种类型的 uri 非常重要。是http、https还是其他方案。在您的情况下,它是Uri.parse(category)。例如,Firefox 可以处理如下方案:httphttpsfileaboutjavascriptpackage。还有 mimeType 的数据:text/htmltext/plainapplication/xhtml+xml

【讨论】:

    猜你喜欢
    • 2019-12-05
    • 2020-05-05
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 2011-01-19
    • 2012-07-19
    • 2012-01-29
    • 2010-11-16
    相关资源
    最近更新 更多