Mainly introduced in the summary of Android development commonly used tool classes, most of the same applies to Java.
currently includeshttputils,Downloadmanagerpro,Safe.ijiami,shellutils,packageutils,preferencesutils,jsonutils,FileUtils,resourceutils,StringUtils,parcelutils,randomutils,arrayutils,imageutils,listutils,maputils,objectutils,serializeutils,systemutils,timeutils.
1, Httputils
HTTP Network tool classes, mainly including HttpGet, HttpPost, and HTTP parameter related methods, take httpget as an example:
Static HttpResponse HttpGet (HttpRequest request)
Static HttpResponse HttpGet (java.lang.String httpurl)
static string httpgetstring (String httpurl)
Contains the above three methods, using GZIP compression by default, using BufferedReader to improve read speed.
HttpRequest can set the URL, timeout, useragent and other HTTP parameters
Return content, HTTP response code, HTTP Expiration Time (Cache-control Max-age and expires) can be obtained in HttpResponse, etc.
The first two methods can be advanced parameter setting and rich content return, the third method can simply pass in the URL to get the return content, httppost similar. More detailed settings can be used directly with the HttpURLConnection or Apache httpclient.
SOURCE VisibleHttputils.java, more methods and more detailed parameters are presentedhttputils Api Guide。
2, Downloadmanagerpro
android system Download Management Downloadmanager enhancement method, which can be used to include information about downloads such as:
Getstatusbyid (long) Get download status
getdownloadbytes (long) Get download progress information
Getbytesandstatus (long) Get download progress information and status
GetFileName (long) Get download file path
GetURI (long) get download URI
GetReason (long) Get download failure or pause reason
Getpausedreason (long) Get download pause reason
GetErrorCode (long) Get download error code
Source visible downloadmanagerpro.java , more methods and more detailed parameter description visible downloadmanagerpro api guide . About Android downmanager using the visible downmanager demo .
3, Safe.ijiami
Android Vulnerability Detection Tool, online upload Android apk, detect the APK development process generated by some vulnerable hackers exploit, attack vulnerability, based on the vulnerability of the corresponding solution, a key to generate detailed analysis report, Let Android developers know the vulnerabilities of their Android apps at a glance and take steps to protect them in a timely manner.
Details Visible http://safe.ijiami.cn , solutions for a variety of applications are visible Http://www.ijiami.cn/appprotect_mobile_games
4, Shellutils
android shell tool class, which can be used to check system root privileges and execute shell commands under the shell or root user. such as: Checkrootpermission () Check root permissions execcommand (string[] commands, boolean isroot, BOOLEAN ISNEEDRESULTMSG) shell Environment Execution command, the second parameter indicates whether the root permission is executed execcommand (String command, boolean isroot) shell Environment Execution Command
source visible shellutils.java , more methods and more detailed parameters are described in the visible shellutils api guide .
5, Packageutils
Android Package related tool class, can be used to (root) install the application, (root) Uninstall the application, determine whether the system application, such as: Install (context, string) Installs the application, if is the system application or already root, then installs silently, otherwise generally installs uninstall (context, string) Uninstalls the application, if is the system application or already root, then silently unloads, Otherwise general uninstall Issystemapplication (context, string) Determine if app is applied for system
source visible packageutils.java , more methods and more detailed parameters are shown shellutils api Guide .
6, preferencesutils
android sharedpreferences related tool classes, which can be used to read and write related types of data to sharedpreferences easily. such as: Putstring (context, string, string) Save String type data
Putint (Context, string, int) Save int type data
getString (context, string) Get String type data
GETINT (context, string) get int type data
can modify Preference_name variable preference name
source visible Preferencesutils.java , more methods and more detailed parameter description visible preferencesutils api guide .
7, Jsonutils
The Jsonutils tool class can be used to easily read and write related types of data to JSON, such as:
String getString (Jsonobject jsonobject, string key, String defaultvalue) Gets the string type value
String getString (String jsondata, String key, String defaultvalue) Gets the string type value
Represents the value of reading a string type key from JSON
Getmap (Jsonobject jsonobject, String key) Get Map
Getmap (string jsondata, String key) Get map
to read the value of a map type key from JSON
Source visible Span style= "COLOR: #3333ff" >jsonutils.java , more methods and more detailed parameters are visible jsonutils api guide .
8, FileUtils
File tool classes, which can be used to read and write files and manipulate files. For example:
ReadFile (string filepath) read files
WriteFile ( String filepath, string content, boolean append) Write file
GetFileSize (string path) Get file size
DeleteFile (string path) Delete files
source visible fileutils.java , more methods and more detailed parameter description visible fileutils api guide .
9, resourceutils
Android resource tool classes, which can be used to read content from the raw and assets directories of the Android resource directory, such as:
Gefilefromassets (context context, string filename) Get a file content in assets directory
Gefilefromraw (CONTEXT CONTEXT, INT RESID) Get a file content from the raw directory
Source visible resourceutils.java , more methods and more detailed parameter description visible resourceutils api guide .
10, StringUtils
String tool class for common string manipulation, such as:
IsEmpty (STRING STR) Determines whether a string is empty or 0
IsBlank (STRING STR) Determines whether a string is empty or has a length of 0 or is made up of spaces
Utf8encode (STRING STR) encode in utf-8 format
Capitalizefirstletter (STRING STR) capitalize
source visible stringutils.java , more methods and more detailed parameters are described in the visible stringutils api guide .
11, Parcelutils
Android parcel tool class that can be used to read or write special types of data from parcel, such as:
Readboolean (parcel in) Read Boolean type data from Pacel
Readhashmap (parcel in, Classloader loader) Read map type data from Pacel
Writeboolean (boolean b, Parcel out) Write Boolean type data to Parcel
Writehashmap (map<k, v> Map, parcel out, int flags) Write map type data to Parcel
Source visible parcelutils.java , more methods and more detailed parameters are visible parcelutils api guide .
&NBSP; 12, Randomutils
Random number tool class, which can be used to obtain random numbers of fixed-size fixed character characters, such as:
Getrandom (char[] sourcechar, int length) Generate random strings, all characters nonspacing within a string
getrandomnumbers (int length) Generate random numbers
source visible randomutils.java , More methods and more detailed parameters are visible randomutils api guide .
13, arrayutils
Array tool class, available for array common operations, such as:
IsEmpty (V[] sourcearray) Determines whether the array is empty or 0
GetLast (v[] sourcearray, v value, v defaultvalue, boolean iscircle) Gets the previous element of an element in the array, iscircle indicates whether to loop
GetNext (v[] sourcearray, v value, v defaultvalue, boolean iscircle) Gets the next element of an element in the array, iscircle indicates whether to loop
source visible arrayutils.java , more methods and more detailed parameters are described in the visible arrayutils api guide .
14, Imageutils
Picture tool classes, which can be used to convert between bitmap, byte array, drawable and image scaling, are currently weak and will be enhanced later. For example:
bitmaptodrawable (bitmap b) bimap convert to drawable
Drawabletobitmap (drawable d) drawable converted to bitmap
Drawabletobyte ( DRAWABLE&NBSP;D) drawable convert to byte
Scaleimage (bitmap org, float scalewidth, float scaleheight) Zoom image
source visible Imageutils.java , more methods and more detailed parameters are described in imageutils api guide .
15, Listutils
list tool class, available for List Common operations, such as:
IsEmpty (list<v> sourcelist) Determine whether the List is empty or 0
Join (list<string> list, String separator) list converted to a string and split with a fixed delimiter
Adddistinctentry (list<v> sourcelist, v entry) Add non-repeating elements to the list
Source visible listutils.java , more methods and more detailed parameters are visible listutils api guide .
16, Maputils
Map tool class, available for map common operations such as
IsEmpty (map<k, v> SOURCEMAP) Determine if the map is empty or 0 Parsekeyandvaluetomap (string source, String keyandvalueseparator, string keyandvaluepairseparator, boolean ignorespace) String parsing to Map
ToJson (map<string, string> map) map converted to JSON format
source visible maputils.java , more methods and more detailed parameters are visible maputils api guide .
17, Objectutils
Object tool class, which can be used for object common use, such as:
Isequals (object actual, object expected) Compare two objects equal
Compare (V&NBSP;V1,&NBSP;V&NBSP;V2) Compare two object sizes
Transformintarray (Int[] source) Integer Array conversion to int array
source visible objectutils.java , more methods and more detailed parameters are described in Span style= "COLOR: #3333ff" >objectutils api guide .
18, Serializeutils
A serialization tool class that can be used to serialize an object to a file or deserialize an object from a file, such as:
Deserialization (String FilePath) Deserializes an object from a file
Serialization (String FilePath, Object obj) serializes objects to a file
Source Visible Serializeutils.java, more methods and more detailed parameters of the serializeutils ApiGuide can be seen.
19, Systemutils
The System Information tool class, which can be used to get the appropriate size of the thread pool, is currently weak and will be enhanced later. Such as:
Getdefaultthreadpoolsize () Get the thread pool size that matches the system configuration
Source Visible Systemutils.java, more methods and more detailed parameters of the systemutils ApiGuide can be seen.
20, Timeutils
Time tool class that can be used for time-related operations such as:
Getcurrenttimeinlong () Gets the current time
GetTime (Long Timeinmillis, SimpleDateFormat DateFormat) converts a long to a fixed-format time string
Source Visible Timeutils.java, more methods and more detailed parameters of the timeutils ApiGuide can be seen.
Most all Android development common tool class