Use xutils3 0 to download project updates

Introduction to xutils

Xutils contains many useful Android tools.

Xutils supports large file upload, more comprehensive HTTP request protocol support (10 predicates), more flexible ORM, more event annotation support, and is not affected by confusion

Xuitls is at least compatible with Android 2.2 (API level 8)

At present, xutils mainly has four modules:

Dbutils module:

In the ORM framework in Android, you can add, delete, modify and query in one line of code; Transactions are supported and closed by default; User defined table name, column name, foreign key, uniqueness constraint, not NULL constraint, check constraint, etc. can be annotated (please annotate table name and column name when confusion is needed); Support binding foreign keys. When saving an entity, the foreign key associated entity is automatically saved or updated; Automatically load foreign key associated entities and support delayed loading; Support chained query expression and more intuitive query semantics. Refer to the following introduction or examples in sample.

Viewutils module:

The IOC framework in Android can bind UI, resources and events in full annotation mode; The new event binding method can still work normally after being confused with the obfuscation tool; At present, there are 20 common event bindings supported. See viewcommoneventlistener class and package com lidroid. xutils. view. annotation. event。

Httputils module:

Support synchronous and asynchronous requests; Support large file upload, and uploading large files will not oom; Support get, post, put, move, copy, delete, head, options, trace, connect requests; The download supports 301 / 302 redirection, and supports setting whether to rename the downloaded file according to the content disposition; Requests that return text content (only get requests are enabled by default) support caching. You can set the default expiration time and the expiration time for the current request.

Bitmaputils module:

When loading bitmap, there is no need to consider the phenomenon of oom in the process of loading bitmap and the picture dislocation in the rapid sliding of Android container; Support loading network pictures and local pictures; Memory management uses LRU algorithm to better manage bitmap memory; Configurable threads, number of loading threads, cache size, cache path, loading display animation, etc

All the above is to pave the way for the following. Let's move on to the theme:

The example written is relatively simple, using xutils3 0 to download project updates

1. First, judge whether the version needs to be updated through the network request

2. If you want to update, a pop-up window will pop up. I use the dialog provided by the system to display the downloaded version number and content prompt

3. When the user clicks download, the download starts, and a horizontal progress bar is displayed during download

4. After downloading, the progress bar disappears and the system is called to install APK

The following is the jar package of xutils used in the code, which is 3.3 Version 32

The above is a small series to introduce to you, using xutils3 0 to download project updates. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>