【问题标题】:Android intent Intent.ACTION_VIEW is opening the third party app embedded inside the app itselfAndroid 意图 Intent.ACTION_VIEW 正在打开嵌入在应用程序本身中的第三方应用程序
【发布时间】:2022-01-08 20:36:07
【问题描述】:

以下代码旨在在浏览器中打开一个链接,但是在某些情况下,如果该链接可以由第三方应用程序打开,它会改为打开第三方应用程序。在某些情况下,第三方应用程序正在打开,嵌入在应用程序本身中。如果进行多任务处理,则可以看到第三方应用程序在应用程序本身内部打开,而第三方应用程序不显示在那里。一种怀疑是第三方应用程序是基于网络的应用程序,但不确定这是否是一个原因。关于可能导致此问题的任何建议?

        if(link.getLink() != null && URLUtil.isValidUrl(link.getLink())) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(link.getLink()));
            startActivity(intent);
        }

【问题讨论】:

    标签: android android-intent


    【解决方案1】:

    通过将以下标志添加到意图以确保创建新任务来解决此问题,尽管仍然未知为什么会发生此行为。

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多