'How solve: Android webview doesn't show images of `img` tag which contains '%2F' in URL

Step 1: Uploaded image on Firebase Storage

Step 2: Stored image's URL in Firestore Database

Step 3: Fetched URL from the database into App

Step 4: Trying to show that image in android Webview

Because the image url contains %2F in the URL Webview doesn't display the image.


val htmlCode = "<img src="https://firebasestorage.googleapis.com/v0/b/project_path/o/sub_path%2Fimage.jpg" />"

webview.loadData(
                htmlCode,
                "text/html",
                "UTF-8"
            )

Problem: Webview doesn't show the image!

I came to know that it is because webview doesn't recognize %2F in the URL.

And converting %2F to / give this error -

{
  "error": {
    "code": 400,
    "message": "Invalid HTTP method/URL pair."
  }
}

How to display the image then?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source