How can I open a Data URI in an external browser using Android Jetpack Compose?

94 Views Asked by At

I am working on an Android project using Jetpack Compose. I am attempting to open a Data URI in an external browser using the LocalUriHandler, but I always encounter a runtime error.

This is my current code:

import androidx.compose.ui.platform.LocalUriHandler

val dataUri = "data:text/html;base64,PGh0bWw+PGJvZHk+PGgxPkhlbGxvLCBXb3JsZCE8L2gxPjwvYm9keT48L2h0bWw+"

val uriHandler = LocalUriHandler.current
uriHandler.openUri("dataUri")

It works perfectly fine using a URL such as "https://www.google.com", but when using a Data URI, it leads to the following exception:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=data: }

I would highly appreciate any help or advice.

0

There are 0 best solutions below