I SWITCHED MY APP FROM SUPPORT V4 TO APPCOMPAT V7
。现在我收到以下错误
02-22 10:48:00.873 10619-11054 / com.makemyandroidapp.example.atlantissites E / ImageLoader:默认情况下UIL不支持scheme(协议)[ http://www.atlantisipad.it/atlantis.ipad/atlantis1_2014.jpg ]。您应该自己实现此支持(BaseImageDownloader.getStreamFromOtherSource(...)) java.lang.UnsupportedOperationException:默认情况下UIL不支持scheme(协议)[ http://www.atlantisipad.it/atlantis.ipad/atlantis1_2014.jpg ]。您应该自己实现此支持(BaseImageDownloader.getStreamFromOtherSource(...)) at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromOtherSource(BaseImageDownloader.java:206) at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:95) at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.saveImageOnDisc(LoadAndDisplayImageTask.java:299) at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:237) 在com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:149) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587) 在java.lang.Thread.run(Thread.java:818)
我通过XML从我的服务器上下载IMMAGE.JPG。并在LISTVIEW中显示图像
@Override
protected Void doInBackground(Void... arg0) {
//Download the file
try {
Downloader.DownloadFromUrl("http://www.atlantisipad.it/atlantis.ipad/AtlantisAndroid.xml", openFileOutput("AtlantisSites.xml", Context.MODE_PRIVATE));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
此处是DOWLOADER CLASS
package com.makemyandroidapp.example.atlantissites;
public class Downloader extends AppCompatActivity {
//Tag for Log statements
private static String myTag = "AtlantisSites";
//Handler msg that represents we are posting a progress update.
static final int POST_PROGRESS = 1;
/************************************************
* Download a file from the Internet and store it locally
*
* @param URL - the url of the file to download
* @param fos - a FileOutputStream to save the downloaded file to.
************************************************/
public static void DownloadFromUrl(String URL, FileOutputStream fos) { //this is the downloader method
try {
URL url = new URL(URL); //URL of the file
//keep the start time so we can display how long it took to the Log.
long startTime = System.currentTimeMillis();
Log.d(myTag, "download begining");
// Open a connection to that URL.
URLConnection ucon = url.openConnection();
// this will be useful so that you can show a tipical 0-100% progress bar
//int lenghtOfFile = ucon.getContentLength();
Log.i(myTag, "Opened Connection");
/************************************************
* Define InputStreams to read from the URLConnection.
************************************************/
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Log.i(myTag, "Got InputStream and BufferedInputStream");
/************************************************
* Define OutputStreams to write to our file.
************************************************/
BufferedOutputStream bos = new BufferedOutputStream(fos);
Log.i(myTag, "Got FileOutputStream and BufferedOutputStream");
/************************************************
* Start reading the and writing our file.
************************************************/
byte data[] = new byte[1024];
//long total = 0;
int count;
//loop and read the current chunk
while ((count = bis.read(data)) != -1) {
//keep track of size for progress.
//total += count;
//write this chunk
bos.write(data, 0, count);
}
//Have to call flush or the file can get corrupted.
bos.flush();
bos.close();
Log.d(myTag, "download ready in "
+ ((System.currentTimeMillis() - startTime))
+ " milisec");
} catch (IOException e) {
Log.d(myTag, "Error: " + e);
}
}
}
答案 0 :(得分:0)
我找到了解决方案。我正在解析的服务器中的xml文件中存在错误。错误是我在链接和</link>