简体   繁体   English

使用phonegap / jquery for android显示来自外部URL的图像

[英]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" 我正在尝试使用phonegap / jquery为Android应用程序显示来自外部URL的图像,但是由于“与服务器的连接失败”而导致应用程序错误

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

Please anyone help on this. 请任何人帮忙。

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 在我的情况下,由于这个原因我得到了问号,希望这可能对将来的其他人有所帮助

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 请参阅此处: http//docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html

另一个可能的问题是您没有将图像源的URL(域)放入phonegap.plist文件中。

只需使用任何图像压缩器剪切图像的大小,并仅使用.jpg图像。

尝试这个

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

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. 在扩展DroidGap的类的onCreate方法中,您需要增加加载HTML文件的超时时间,以便获取远程图像。 Add... 加...

super.setIntegerProperty("loadUrlTimeoutValue", 60000);

to your onCreate method. 你的onCreate方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM