Get Request Example
All parameters are using bundles, with putstringbundle bundle = new Bundle (), bundle.putstring ("username", "Rederxuget"), Bundle.putstring ( "Password", "Farmerget");//urlstring url = "http://www.baidu.com";//Initiate request Httprequest.get (This,url, bundle, new Onrequestoverlistener () { @Override public void Onrequestover (String result) { //Returns the result (or error reason) LOG.E ( "Onrequestover", result);} );
The POST request is consistent with the GET request, and only the calling method is different.
Post Request Example
All parameters are using bundles, with putstringbundle bundle = new Bundle (), bundle.putstring ("username", "Rederxuget"), Bundle.putstring ( "Password", "Farmerget");//urlstring url = "http://www.baidu.com";//Initiate request Httprequest.post (This,url, bundle, new Onrequestoverlistener () { @Override public void Onrequestover (String result) { //Returns the result (or error reason) 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 complete, 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.E ("upload", result) returned after successful upload of the server;} );
Framework and Demo Files http://www.ideayapai.com/Application/Home/View/default/PowerFamily/index-2.htm
Welcome to Daniel, the great God visit QQ Group to Exchange: 575026537
Open source Android Development Framework-------Powerframework Use (v) Network request HttpRequest