ActivityNotFoundException crash when starting "open url" intent on Chrome 86.0.4240.75

757 Views Asked by At

Chrome for Android version 86.0.4240.75 was released just a few days ago. The rollout has barely started, but we're seeing a new crash whose numbers are going straight up, on devices using that version of Chrome / Android System WebView.

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

It looks like for any url, on any device using version 86.0.4240.75, the above code crashes with 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)

Seems like a bug in Chrome, but has anyone figured out a workaround yet?

1

There are 1 best solutions below

0
On

A bit surprising, but I found an easy workaround. Actually two: remove the MIME type or remove the category.

This works fine even with 86.0.4240.75:

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

This does too:

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

(I'm not sure what the benefit of defining text/html or CATEGORY_BROWSABLE was in the first place, as neither seems mandatory.)