画像ダウンローダーを実装しようとしています。
これが私が使用した例です:http: //android-developers.blogspot.de/2010/07/multithreading-for-performance.html
しかし、残念ながら、私はたくさんの警告を受け取り、その結果、画像が表示されません。
https://www.dropbox.com/s/jpstbcehoii2xt7/snipp2.PNG
runOnUiThread(new Runnable() {
public void run() {
final Handler uiHandler = new Handler();
Timer myTimer = new Timer(); // Timer erzeugen
myTimer.schedule(new TimerTask() {
@Override
public void run() {
try{
imageDownloader.download("http://osthessen-news.de/Media/13/03/News130308_10_DSC_2375.jpg_Thumbnail0.jpg", (ImageView) mainImage1);
} catch (Exception e) {
e.printStackTrace();
}
}
}, 0L, 60L * 1000); //Intervall = 60000 Millisekunden, 0 Millisekunden bis zum ersten Start.
}});
03-08 14:22:14.577: W/ImageDownloader(12411): Error while retrieving bitmap from http://osthessen-news.de/Media/13/03/News130308_10_DSC_2375.jpg_Thumbnail0.jpg
03-08 14:22:14.577: W/ImageDownloader(12411): android.os.NetworkOnMainThreadException
03-08 14:22:14.577: W/ImageDownloader(12411): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
03-08 14:22:14.577: W/ImageDownloader(12411): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
03-08 14:22:14.577: W/ImageDownloader(12411): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
03-08 14:22:14.577: W/ImageDownloader(12411): at java.net.InetAddress.getAllByName(InetAddress.java:214)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-08 14:22:14.577: W/ImageDownloader(12411): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)