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