Use of Android Volley framework (2)

Source: Internet
Author: User

3. Setting the request type and parameters

Volley the default request type is get, which can be set in the constructor if a post is required. Setting parameters can be implemented by overriding the Getparams () method.

    Private voidpostrequest () {jsonobjectrequest postobjectrequest=Newjsonobjectrequest (Method.post,"Http://192.168.199.18:8080/myhos/query",                NULL,                NewResponse.listener<jsonobject>() {@Override Public voidOnresponse (jsonobject response) {LOG.I ("Response:", response.tostring ()); }                },                NewResponse.errorlistener () {@Override Public voidonerrorresponse (volleyerror error) {LOG.I ("Error:", Error.getmessage (), error); }}) {@OverrideprotectedMap<string, string> getparams ()throwsAuthfailureerror {Map<string, string> map =NewHashmap<string, string>(); Map.put ("QID", "446"); Map.put ("Count", "10"); Map.put ("Page", "1"); returnmap;        }        };    Mqueue.add (postobjectrequest); }

In the code above, another constructor for the volley request is used, the request is specified as post by Method.post, and three parameters are set by overriding the Getparams () method. The results of the operation are as follows:

Use of Android Volley framework (2)

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.