sujai
sujai

Reputation: 61

Display an image from external url using phonegap/jquery for android

I am trying to display an image from external url like below using phonegap/jquery for android app but getting application error as "connection to the server was unsuccessful"

img src="http://www.techinasia.com/techinasia/wp-content/uploads/2009/12/Search.jpg"

Please anyone help on this.

Upvotes: 3

Views: 10295

Answers (6)

When you're generating the whitelist links, make sure there's no slash "/" at the end of the url.

<access origin="http://google.com" /> <!--  this works -->
<access origin="http://google.com/" /> <!-- this doesn't -->

In my case I was getting the question marks because of this, hope this could be helpful for someone else in the future

Upvotes: 5

Rudolf
Rudolf

Reputation: 41

You need to put the external website on the whitelist. See how to here: http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html

Upvotes: 4

nihalkhan
nihalkhan

Reputation: 1

Just cut the size of the image using any image compressor and use only .jpg images.

Upvotes: 0

user1344344
user1344344

Reputation: 21

One other possible problem is that you did not put the URL (domain) of the image source into the phonegap.plist file.

Upvotes: 0

Simon MacDonald
Simon MacDonald

Reputation: 23273

In the onCreate method of the class that extends DroidGap you'll want to increase the timeout of loading the HTML file so you can get the remote image. Add...

super.setIntegerProperty("loadUrlTimeoutValue", 60000);

to your onCreate method.

Upvotes: 0

vicky
vicky

Reputation: 705

Try this

<a href="#"><img src="http://www.techinasia.com/techinasia/wp-content/uploads/2009/12/Search.jpg"  data-rel="external"/></a>

Upvotes: 0

Related Questions