【问题标题】:ActivityNotFoundException crash when starting "open url" intent on Chrome 86.0.4240.75在 Chrome 86.0.4240.75 上启动“打开 url”意图时 ActivityNotFoundException 崩溃
【发布时间】:2021-01-24 13:49:32
【问题描述】:

Chrome for Android version 86.0.4240.75 几天前刚刚发布。部署刚刚开始,但我们看到使用该版本的 Chrome/Android System WebView 的设备上出现了新的崩溃,其数量正在直线上升。

val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse(url), "text/html")
intent.addCategory(Intent.CATEGORY_BROWSABLE)
startActivity(intent)

对于 any url,在使用版本 86.0.4240.75 的 any device 上,上述代码会因 ActivityNotFoundException 而崩溃:

android.content.ActivityNotFoundException: No Activity found to handle Intent 
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1854) 
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1544)

似乎是 Chrome 中的一个错误,但有人找到解决方法了吗?

【问题讨论】:

    标签: android android-webview android-chrome


    【解决方案1】:

    有点令人惊讶,但我找到了一个简单的解决方法。实际上有两个:删除MIME类型或删除类别

    即使使用 86.0.4240.75 也能正常工作:

    val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
    intent.addCategory(Intent.CATEGORY_BROWSABLE)
    startActivity(intent)
    

    这也是:

    val intent = Intent(Intent.ACTION_VIEW)
    intent.setDataAndType(Uri.parse(url), "text/html")
    startActivity(intent)
    

    (我不确定首先定义 text/htmlCATEGORY_BROWSABLE 有什么好处,因为这两者似乎都不是强制性的。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-06
      相关资源
      最近更新 更多