To get the picture on the network, first of all have access to the network, this no longer write, the previous article has written, there is no longer the layout of the writing, is written is also a simple layout, not much meaning, directly on the core code:
This is a simple class that I use to get pictures on the web.
public static Bitmap GetImage (String Url) throws Exception {
try {
URL url = new url (URL);
String responsecode = Url.openconnection (). Getheaderfield (0);
if (Responsecode.indexof ("M") < 0)
throw new Exception ("Picture file does not exist or path error, error code:" + responsecode);
Return Bitmapfactory.decodestream (Url.openstream ());
catch (IOException e) {
TODO auto-generated Catch block
throw new Exception (E.getmessage ());
}
}
This class returns a Bitmap object,
The following is a simple call to a class:
Directly on the code:
Bitmap Mbitmap;
Get Pictures directly:
private void Refreshdb () {
try {
Sendmsg (Declare.start, "Loading pictures ...");
Mbitmap = downfile.getimage (picture address);
Sendmsg (Declare.stop, "");
catch (Exception e) {
TODO auto-generated Catch block
Sendmsg (Declare.error, E.getmessage ());
}
Here with a simple scroll bar, indicating that the current program is executing, through the way of sending a message, the specific no longer write, that message headless this core code implementation.
To execute after the load completes:
Mimageview1.setimagebitmap (MBITMAP);