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.