Share two tool classes that simulate the get and post methods to enable the application to interact with the server.

Source: Internet
Author: User
Tags string back

There has been no code word for a long time. Today, I want to share with you a tool class that simulates get and post methods. Many Android apps need to interact with the server in terms of data, first, the server will provide some data interaction interfaces to the application. But how can I call them in the application? This requires the get and post methods. The following are two tool classes that you have summarized and are always using. Please refer to the Code:

 .ctx =.url =.callback ==   post_thread .url =.ctx ==                                  String back =             = ===               String post(String url) = ""= = = code = (code == 200== [] buffer =  [1024 len = 0 ((len = is.read(buffer)) != -10[] b ==  String(b, "utf-8"

  ArrayList<NameValuePair> data =  doPost(Context ctx, String url, ArrayList<NameValuePair>.ctx =.url =.callback =.data ==   post_thread  ArrayList<NameValuePair><NameValuePair>.url =.ctx =.data ==                                  String back =             = ===               String post(String url) = ""= =  UrlEncodedFormEntity(data, "utf-8"= code = (code == 200== [] buffer =  [1024 len = 0 ((len = is.read(buffer)) != -10[] b == 

Interface used for data callback:

  

 

After obtaining data from the database, it is necessary to parse the data and extract the required data for use. This is also very simple and will be shared next time.

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.