Ich lerne Android-Programmierung und was ist Fehler?Bild herunterladen von URL
ImageView im = (ImageView) findViewById(R.id.imageView);
try {
URL u = new URL("http");
HttpURLConnection ur = (HttpURLConnection) u.openConnection();
InputStream in = ur.getInputStream();
Bitmap bs = BitmapFactory.decodeStream(in);
im.setImageBitmap(bs);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
Verwenden Sie LogCat, um die Java-Stack-Ablaufverfolgung zu untersuchen, die mit Ihrem Absturz verknüpft ist: https://stackoverflow.com/questions/23353173/unidy-myapp-has-stopped-how-can-i-solve-this. Höchstwahrscheinlich werden Sie feststellen, dass Sie mit einer "NetworkOnMainThreadException" stürzen: http://stackoverflow.com/questions/6343166/how-to-fix-android-os-networkonmainthreadexception – CommonsWare
http://stackoverflow.com/a/ 3090802/5915572 –