1

The payment platform I am using for my app provides a barcode image in SVG format, as below:

https://api.omise.co/charges/chrg_test_5d90i5vu8tv6vm0q4ah/documents/docu_test_5d90i5wz0qmrc7ogg1j/downloads/FD1649EF22456F4B

How do I take that string/url and display the image in an ImageView? If I paste that string in my browser, it downloads the SVG file.

Do I need to convert the file to/from SVG format into the required format? If so, how would I do that?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Todd
  • 55
  • 1
  • 7
  • If you are getting an error, then please post the relevant code. Lots of people are using Glide and AndroidSVG successfully, so it is almost certainly an issue with your code. But we can't tell you what is wrong with code we cannot see. – Paul LeBeau Sep 13 '18 at 16:32

2 Answers2

1

Since ImageView on Android doesn't support SVG natively. You can download the SVG as a string value and load it into a WebView in place of the ImageView.

Darryl E. Clarke
  • 7,537
  • 3
  • 26
  • 34
0

I'd recommend using Glide. This answer should help you more than anything I can write here. You probably don't even need to go to the answer section, the OP includes code for handling an SVG with Glide.

Does Glide have a method for loading both PNG and SVG?

https://github.com/bumptech/glide

rexar5
  • 470
  • 2
  • 10
  • Was using Glide and my code follows their provided samples for SVG images, but I keep getting the following error: "com.bumptech.glide.load.engine.GlideException: Failed to load resource ". So I'm not sure if i am missing a step such as converting the provided url string to ".svg" format? But not sure. – Todd Sep 12 '18 at 21:18
  • Yeah, you would need to have the URL just point directly to the svg file instead of being a download link. You could probably download the file and point Glide to a local URL too, but modifying your back-end would make things a lot simpler. – rexar5 Sep 13 '18 at 20:09