An example of this article is a simple way to get a picture on a network with Android programming. Share to everyone for your reference, specific as follows:
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) < 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 picture directly:
private void Refreshdb () {
try {
sendmsg (declare.start, loading picture ...);
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);
For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android Development introduction and Advanced Course", "Android debugging techniques and common problems solution summary", " Android Multimedia How-to Summary (audio, video, audio, etc), summary of Android Basic components usage, Android View tips Summary, Android layout layout tips and a summary of Android controls usage
I hope this article will help you with the Android program.