Example of image upload and download function realized by Android programming

This paper gives an example of Android programming to realize the function of uploading and downloading pictures. Share with you for your reference, as follows:

When implementing an Android web service client, such as microblog and forum client, we often use image upload and download. Here we introduce how to use httpclient to upload and download pictures.

1 picture upload: when uploading a picture, first obtain the path of the picture, create a file, convert the picture into a byte stream, write it to the request, and send the request.

Client code:

The work of the server is to receive the byte stream, write it to the file, save the file in the corresponding folder in the server, record the path of the file, and write the path of the picture file to the database for saving.

Server side code:

2 picture download: first obtain the picture address of the network picture. After sending the request, the server will return the byte stream of the picture, and use the bitmapfactory. Decodestream() method to convert the byte stream into a picture and return it. The specific codes are as follows:

More readers interested in Android related content can view the special topics of this site: summary of Android graphics and image processing skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and solutions to common problems, summary of Android multimedia operation skills (audio, video, recording, etc.), summary of Android basic component usage Summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>