Search code examples
androidhtmlintel-xdk

XDK - How to load an image from an URL in android using img tag


I made my app in XDK, but until now I was using it purely online, in a server. Now I want to 'convert' it into an android app. The main problem i'm having is that in some areas of this app, I need to import an image from an URL, like so:

<img ng-src="https://i.ytimg.com/vi/3YJpUROvQAk/maxresdefault.jpg">

But in my android device, all images do not load. Is there any way to load an image from an URL into a img tag with XDK Android?


Solution

  • This is generally not a good idea, because it means you are dependent on the presence of a good and working Internet connection when your app runs. This cannot be guaranteed:

    • the device network connection may be slow or off
    • using the network to load these images each time you run uses valuable (and potentially expensive) data on your customer's data plan
    • lack of a connection can, at the worst, block your app so it appears to be hung

    If you want to do what you are attempting to do you'll need to make sure your whitelist is configured to include access to the locations from which you are attempting to load the image. This is probably why it is failing.