036 Android Xutils3 framework uses network requests

1.xUtils3 Introduction

xUtils currently includes four major modules, namely DbUtils modules, ViewUtils module, and the module HttpUtils BitmapUtils module.

xUtils3 network module greatly facilitate the development of network modules in the actual development, xUtils3 network module generally includes GET requests, POST requests, how to use other ways request, upload files, download files, use caching and other functions.

This article focuses on explaining: Use HttpUtils module.

2.xUtils3 main features are as follows:

(1) the cornerstone of stability: AbsTask and unified callback interface Callback, any exceptions, even if you have abnormal callback method implementation will enter onError, under any circumstances onFinished will always let you know the mission is over.

(2) based on the highly efficient and stable orm tools, http module can more easily achieve cookie (support domain, path, expiry and other characteristics) and caching (support Cache-Control, Last-Modified, ETag and other characteristics) support.

(3) With a strong http download cache and support to achieve image module is quite simple, and supports recovery view is held, but was removed Mem Cache picture, reduce flicker when the page rollback.

(4) View annotation module just over 400 lines of code but flexible support for various View and event bindings injection, including the method has a number of listener support.

Key features 3. HttpUtils module.

(1) support synchronous, asynchronous mode is requested.

(2) support for large file upload, upload large files will not appear oom memory overflow.

(3) support GET, POST, PUT, MOVE, COPY, DELETE, HEAD, OPTIONS, TRACE, CONNECT request.

(4) Download Support 301/302 redirection, support settings are based on Content-Disposition rename the downloaded file.

(5) returns the text content of the request (enabled by default only GET requests) supports caching, you can set the default expiration time and expiration time for the current request.

4.xUtils3 use environment configuration

(1) add dependencies

implementation 'org.xutils:xutils:3.5.1'

(2) add permissions in the manifest file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 

Guess you like

Origin www.cnblogs.com/luckyplj/p/10935395.html