============ Problem Description ============
is the Webroot folder for my MyEclipse project,
I wanted to download the pictures in this folder, but I found that there was a strange mistake. In addition to test01_upload_1.jpg, other pictures are displayed filenotfoundexception.
Here is my test code and error message.
package com.example.imagedownload;import java.io.ioexception;import java.net.malformedurlexception;import java.net.url;import android.app.activity;import android.graphics.drawable.drawable;import android.os.bundle;import android.os.handler;import android.os.message;import android.widget.imageview;public class mainactivity extends activity {private imageview imageview;private string imageurl = "/http 10.0.2.2:8080/bbstuservlet/573da5540dee470f9ec41de207e83b73.jpg ";final handler handler = New handler () {@Overridepublic void handlemessage (message msg) { System.out.println (msg.obj); Imageview.setimagedrawable ((drawable) msg.obj);}; @Overrideprotected void oncreate (bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (R.layout.activity_main);imageview = (ImageView) findViewByID (r.id.imageview1); New thread (new runnable () {@Overridepublic void run () {try {drawable drawable = drawable.createfromstream (New url (IMAGEURL). OpenStream (), "Image.jpg"); System.out.println ("draw = " + drawable); Message msg = new message (); Msg.obj = drawable;handler.sendmessage (msg);} catch (malformedurlexception e) {// TODO Auto-generated catch Blocke.printstacktrace ();} catch (ioexception e) {// TODO Auto-generated catch Blocke.printstacktrace ();}}). Start ();}}
09-28 12:29:28.243: e/surfaceflinger (PNS): ro.sf.lcd_density must be defined as a build property09-28 12:29:28.334: e/trace (3029): error opening trace file: No such file or directory (2) 09-28 12:29:28.684: w/system.err (3029): java.io.filenotfoundexception: http://10.0.2.2:8080/bbstuservlet/ 573da5540dee470f9ec41de207e83b73.jpg09-28 12:29:28.724: w/system.err (3029): at Libcore.net.http.HttpURLConnectionImpl.getInputStream (httpurlconnectionimpl.java:186) 09-28 12:29:28.724: w/system.err (3029): at java.net.url.openstream (url.java:462) 09-28 12:29:28.724: w/ System.err (3029): at com.example.imagedownload.mainactivity$2.run (mainactivity.java:40) 09-28 12:29:28.735: w/system.err (3029): at java.lang.thread.run (thread.java:856) 09-28 12:29:28.774: e/surfaceflinger (PNS): ro.sf.lcd_Density must be defined as a build property
Strange problem, if it is all downloaded, may be code or configuration problems, but some can download, and some cannot, it is very strange. Which great God can help me to solve the problem for two days.
============ Solution 1============
Don't you see that the permissions on your other images are different from the permissions of 1.jpg? You check how you change the right, and then it's Ok.
PS: No matter which platform developed Android is the same, the development tools are consistent, no difference
Android Download picture problem from server