Open-source Android development framework ------- PowerFramework experiences (5) network requests for HTTPRequest and. netframework open-source

Source: Internet
Author: User

Open-source Android development framework ------- PowerFramework experiences (5) network requests for HTTPRequest and. netframework open-source

GET request example

// All parameters use Bundle, and putStringBundle = new bundle (); Bundle. putString ("username", "RederXuGet"); bundle. putString ("password", "farmerGet"); // urlString url = "http://www.baidu.com"; // initiate the request HTTPRequest. GET (this, url, bundle, new onRequestOverListener () {@ Override public void onRequestOver (String result) {// return result (or error cause) Log. e ("onRequestOver", result );}});

The post request and get request are written in the same way, except that the call method is different.

POST request example

// All parameters use Bundle, and putStringBundle = new bundle (); Bundle. putString ("username", "RederXuGet"); bundle. putString ("password", "farmerGet"); // urlString url = "http://www.baidu.com"; // initiate the request HTTPRequest. POST (this, url, bundle, new onRequestOverListener () {@ Override public void onRequestOver (String result) {// return result (or error cause) Log. e ("onRequestOver", result );}});

File Download

String url = "http: // 192.168.1.174: 8020/video1.mp4"; String path = "/mnt/sdcard/"; HTTPRequest. fileDownload (url, path, true, new onFileDownloadListener () {@ Override public void onDownloading (int max, int progress) {// TODO Auto-generated method stub Log. e ("download progress", progress + "/" + max) ;}@ Override public void onDownloadOver (String result) {Log. e ("download completed, storage location:", result );}});

 File Upload

String uploadUrl = "http: // 192.168.1.174: 8020/android/FileUpload. php "; String filePath ="/mnt/sdcard/screenshot.png "; HTTPRequest. uploadFile (uploadUrl, filePath, new onRequestOverListener () {@ Override public void onRequestOver (String result) {// Log of the information returned after the Server Upload is successful. e ("upload", result );}});

  

 

Framework and DEMO file http://www.ideayapai.com/Application/Home/View/default/PowerFamily/index-2.htm

 

Welcome to the QQ Group for discussion: 575026537

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.