Litehttp Minimalist and Smart Android HTTP framework

Source: Internet
Author: User

Today comes into contact with the litehttp framework, feel very good, more lightweight than vollery. For more information and usage, please refer to:

Http://www.eoeandroid.com/thread-326584-1-1.html

Here is a detailed introduction, here is a brief introduction of how to use this framework to send a request to the server, to complete the client user name and password verification.

GitHub Links:

Https://github.com/litesuits/android-lite-async

1. Use the above connection to download the appropriate Litehttp.jar, reference it in the project (Eclipse and Andriod Studio reference methods are different, please handle separately).

2. Initialization

Liteclient = litehttpclient.newapachehttpclient (context);
Httpasyncexecutor Asyncexecutor = httpasyncexecutor.newinstance (client);

3. Send the request, here will send a verification to the server loginurl, followed by the user name and password, and then the server (provided that the server interface is OK) will return a JSON string (including authorize and version two properties), Apiloginreturn This object defines the service side to return the properties in the JSON string (authorize, Version). When the validation is successful, the framework automatically resolves the JSON string returned by the server and then automatically encapsulates the returned value into the Apiloginreturn object, which verifies that the user name and password are correct based on the return value of authorize in the Apiloginreturn object. Verification of success and failure has a corresponding callback function, can be based on different scenarios to do different logic processing.

asyncexecutor.execute (New Request (loginurl), new Httpmodelhandler<apiloginreturn> () {
                @Override
                protected void onsuccess (Apiloginreturn o, Response Response) {
                    if (o.authorize) {
        & nbsp               Toast.maketext (context, "verified success", Toast.length_long). Show ();


                   } else {
                Toast.maketext       (cont) Ext, "Verification failed", Toast.length_long). Show ();
                   }
               }
                @Override
                protected void OnFailure (HttpException E, Response Response) {
                    Toast.maketext (context, "Verify connection failed, check network connectivity", Toast.length_long). Show ();
               }
           });

public static class Apiloginreturn {
public Boolean authorize; Validation results
Public String Version; Version number
}

Other features, such as the multi-file upload feature, can refer to the above post.


Litehttp Minimalist and Smart Android HTTP framework

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.