use
- The library is still in the process of iterating on features.
The compile 'com. Code19. Library: the library: 0.0.7'Copy the code
Common Tool Classes
- Every Android developer accumulates snippets of their own code during daily development
- Objective:
- 1. Make common function modules into tool classes
- 2. Encapsulate Android SYSTEM API to simplify the use of API
- 3. Collect efficient and correct snippets of code to avoid next stumbles
- 4. Rely on third parties as little as possible
- General ability, limited level, inevitable bugs, if there is any problem, please feedback
- If you have better code, please submit the Pull Request
Library Module classes:
-
Apputils. Java application utility class
- GetAppName Obtains the application name
- GetAppIcon gets the app icon
- GetAppDate Obtains the application update date
- GetAppSize Obtains the application size
- GetAppApk Obtains the application APK file
- GetAppVersionName Obtains the application version name
- GetAppVersionCode Obtains the application version
- GetAppInstaller Obtains the application installation market
- GetAppPackageName Indicates the name of the application package
- HasPermission indicates whether it hasPermission
- IsInstalled indicates whether the application isInstalled
- InstallApk Installs applications
- UninstallApk Uninstalls applications
- IsSystemApp Is a system application
- IsServiceRunning Whether the service is running
- StopRunningService Stops the service
- GetNumCores Specifies the number of Cpu cores
- KillProcesses Terminates processes
- RunScript Runs the script
- GetRootPermission Obtains the root permission
-
Java Bitmap utility class
- DecodeFile parses files to bitmap
- GetImageThumbnail gets the thumbnail of the picture
-
Cacheutils.java Cache utility class
- SetCache Sets the cache
- GetCache Retrieves the cache
-
Cipherutils.java password utility class
- Encode (String input) retrieves the MD5 value of the String
- Encode (InputStream in) gets the md5 value of the InputStream
- Base64Encode Base64 encryption
- Base64Decode Base64 decryption
- XorEncode xor encryption
- XorDecode Xor decryption
-
CoordinateTransformUtil. Java GPS coordinates conversion tool
- Baidu coordinates (BD09), national bureau of Measurement coordinates (Mars coordinates, GCJ02), and WGS84 coordinate system conversion tool
- Bd09towgs84 Baidu coordinate system (BD-09) to WGS coordinates (Baidu coordinates latitude, Baidu coordinates longitude),WGS84 coordinate array
- Wgs84tobd09 WGS coordinates to Baidu coordinate system (BD-09)(longitude of WGS84 coordinate system, latitude of WGS84 coordinate system), Baidu coordinate array
- Gcj02tobd09 Mars coordinate system (GCJ-02) to Baidu coordinate system (BD-09)(Mars coordinate longitude, Mars coordinate latitude), Baidu coordinate array
- Bd09togcj02 Baidu coordinate system (BD-09) to Mars coordinate system (GCJ-02)(Baidu coordinates latitude, Baidu coordinates longitude), Mars coordinate array
- Wgs84togcj02 WGS84 to GCJ02(Mars coordinate system)(longitude of WGS84 coordinate system, latitude of WGS84 coordinate system), Array of Mars coordinates
- Gcj02towgs84 GCJ02(Mars coordinate system) to GPS84(Mars coordinate system longitude, Mars coordinate system latitude),WGS84 coordinate array
- Transformlat Latitude conversion
- Transformlng longitude conversion
- Out_of_china Checks whether the device is in the country. If the device is not in the country, no offset is performed
-
Dateutil. Java date utility class
- FormatDataTime Format the date and time
- FormatDate Formatting date
- FormatTime Formatting time
- FormatDateCustom Format date and time of a custom format
- String2Date converts the time string to Date
- GetTime Obtains the system time
- SubtractDate Computes two time differences
- GetDateAfter gets the time in a few days
- GetWeekOfMonth Gets the current week of the month
- GetDayOfWeek Gets the current day of the week
-
Densityutil. Java screen utility class
- Dip2px DP to pixels
- Px2dip pixel to DP
- Px2sp pixel to SP
- Sp2px sp to pixels
- GetScreenW Gets the screen width
- GetScreenH gets the screen height
- GetScreenRealSize Gets the true height of the screen
- GetStatusBarH Gets the height of the status bar
- GetNavigationBarrH Gets the height of the navigation bar
-
Deviceutils. Java Device information tool
- GetAndroidID get AndroidID
- GetIMEI Obtains the IMEI of the device
- GetIMSI Obtains the IMSI code of the device
- GetWifiMacAddr Obtains the MAC address
- GetIP Obtaining network IP address (obtaining wifi address is preferred)
- GetWifiIP Obtains the WIFI IP address
- GetGPRSIP Obtains the IP address of the GPRS connection
- GetSerial Obtains the device serial number
- GetSIMSerial Obtains the SIM serial number
- GetPhoneNumber Obtaining the mobile phone number (failed)
- GetMNC obtains network operators 4600046002 46007 China Mobile,46001 China Unicom,46003 China Telecom
- GetCarrier obtains network operators: China Telecom, China Mobile, China Unicom
- GetModel Obtains the hardware model
- GetBuildBrand gets the build manufacturer
- GetBuildHost gets the build server host
- GetBuildTags gets the tag that describes the Build
- GetBuildTime gets the system build time
- GetBuildUser gets the system build author
- GetBuildVersionRelease Gets the build system version (5.1)
- GetBuildVersionCodename gets the development code
- GetBuildVersionIncremental for source control version number
- GetBuildVersionSDK gets the compiled SDK
- GetBuildID Get the list of revisions (LMY47D)
- GetSupportedABIS CPU instruction set
- GetManufacturer Obtains the hardware manufacturer
- GetBootloader Gets the system boot program version number
- getScreenDisplayID
- GetDisplayVersion Obtains the system version number
- GetLanguage gets the language
- GetCountry Obtains the country
- GetOSVersion Obtain the system version :5.1.1
- GetGSFID retrieves the GSF serial number
- GetBluetoothMAC Obtains the Bluetooth address
- GetPsuedoUniqueID Unique physical IDENTIFIER of an Android device
- GetFingerprint build identification, including brand name, device, version. Release, id, version, incremental, type, tags the information
- GetHardware retrieves hardware information
- GetProduct Gets product information
- GetDevice Obtains device information
- GetBoard Obtains information about the mainboard
- GetRadioVersion Get baseband version (radio firmware version Api14 or above)
- Browser fingerprint obtained by getUA (user-agent)
- GetDensity obtains the screen density
- GetGoogleAccounts Obtains the Google account
-
Java file utility class
- CloseIO Closes the I/O stream
- IsFileExist Whether the isFileExist file exists
- WriteFile writes a string to a file
- ReadFile reads a string from a file
- CopyFileFast Fast copy
- ShareFile Shares a file
- Zip zip
- Unzip the zip decompression
- FormatFileSize formatFileSize
- Stream2File writes the input stream to a file
- CreateFolder Creates a folder
- CreateFolder createFolder (support overwriting existing folders of the same name)
- GetFolderName Gets the folder name
- DeleteFile Deletes files from a directory
- OpenImage opens the image
- OpenVideo Displays a video
- OpenURL open the URL
-
Imageutils. Java image utility class
- CalculateInSampleSize calculates the compression ratio of the image
- GetPictureDegree gets the Angle of the image
- RotaingImageView rotates the image
- DecodeScaleImage loads images and compresses them
- //* decodeUriAsBitmap parses the URL stream into images
- Bitmap2File The bitmap is saved as a file
- CompressImage Quality compression
- CompressFixBitmap Fixed-size compression
-
Jsonutils.java Json utility classes (dependent on Gson 2.0 or above)
- ToJson object toJson
- FromJson Json to object
- MapToJson Converts a Map to a JSONObject
- Collection2Json collection is converted to JSONArray
- Object2Json Object Converts the Object to JSONArray
- String2JSONObject JSON String Generates a JSONObject
-
L. Java logging tool
- Init Initializes the log switch and TAG(default log is on and TAG is “ghost”)
- v VERBOSE
- d DEBUG
- i INFO
- w WARN
- e ERROR
- a ASSERT
- Json output json
- The XML output XML
-
Netutils. Java networking tools
- GetNetworkType Obtains the network type
- GetNetworkTypeName Obtains the network name
- IsConnected Checks the network status
- IsNetworkAvailable Indicates the network availability
- Whether isWiFi wifi
- OpenNetSetting Displays the network setting screen
- SetWifiEnabled Sets the wifi status
- GetWifiScanResults gets the wifi list
- GetScanResultsByBSSID Filter scan results
- GetWifiConnectionInfo Obtains wifi connection information
-
SPUtils. Java SharedPreferences tools
- SetSP stores the SharedPreferences value
- GetSp obtains the SharedPreferences value
- CleanAllSP cleans up all SP values
-
Stringutils.java string tool
- GetChsAscii Converts Chinese characters to ASCII characters
- Convert word parsing
- GetSelling phrase parsing
- ParseEmpty converts null to”
- IsEmpty is an empty string
- ChineseLength chineseLength
- StrLength Length of the string
- SubStringLength Gets the position of the character of the specified length
- IsChinese indicates whether it isChinese
- IsContainChinese Specifies whether it contains Chinese
- StrFormat2 is less than 2 bits preceded by 0
- Convert2Int Type security conversion
- DecimalFormat Specifies decimal output
-
Systemutils.java System tools
- SendSMS invokes the system to sendSMS messages
- ForwardToDial Jumps to dial
- CallPhone Indicates the number of a direct call
- The sendMail mail
- HideKeyBoard Hides the system keyboard
- IsBackground checks whether the current application is running in the background
- IsSleeping Determine whether the phone handles sleep
- InstallApk install apk
- Whether isRooted root
- IsRunningOnEmulator Whether the current device is an emulator
- GetAppVersionName Gets the version name of the current application
- GetAppVersionCode gets the version number of the current application
- Return to the Home goHome
- GetSign obtains the application signature
- Hexdigest 32-bit signature
- GetDeviceUsableMemory Gets the available space of the device
- The GC cleans up background processes and services
- CreateDeskShortCut Creates a desktop shortcut
- CreateShortcut Creates a shortcut
- ShareText Shares the text
- ShareFile Shares files (this method is the way in calling Fileutils.sharefile)
- GetShareTargets Obtains the applications that are acceptable for sharing
- GetCurrentLanguage Gets the language of the current system
- GetLanguage gets the language of the current system
- IsGpsEnabled Whether GPS is enabled
- ShowSoftInputMethod Displays the soft keyboard
- CloseSoftInputMethod closes the soft keyboard
- ShowSoftInput Displays the soft keyboard
- CloseSoftInput turns off the soft keyboard
-
The verificationUtils.java validation utility class
-
MatcherRealName Determines the name format
Real names can be Chinese characters or letters, but not both, and they cannot contain any symbols or the number 1. If it is an English name, you can allow a space of 2. Multiple Spaces can be used in an English name, but multiple 3's cannot be used in a row. Chinese characters cannot have SpacesCopy the code
-
MatcherPhoneNum Determine the mobile phone number format (matching 11 digits and starting with 13-19)
- MatcherAccount Determine the account format (4-20 characters)
- MatcherPassword Determine the password format (6-12 letters or numbers)
- MatcherPassword2 Determine the password format (6-12 letters or numbers must contain both letters and numbers)
- MatcherEmail Determines the email address format
- MatcherIP Indicates the IP address
- MatcherUrl Determine the URL (HTTP, HTTPS, FTP)
- Matchervehicular judge Chinese civilian vehicle number plate
- MatcherIdentityCard Identifies the id card number format
- IsNumeric isNumeric
- TestRegex specifies whether the testRegex matches the re
- CheckPostcode matches the Chinese zip code
-
-
ViewUtils. Java View tool
- removeSelfFromParent
- requestLayoutParent
- isTouchInView
- bigImage
- SetTVUnderLine sets the underline to the TextView
- showPopupWindow
- dismissPopup
- CaptureView screenshots
- CreateViewBitmap screenshots
- ConvertViewToBitmap screenshots
- GetActivityBitmap Gets a screenshot of the Activity
- GetStatusBarHeight Gets the status bar height
- GetToolbarHeight Gets the height of the toolbar
- GetNavigationBarHeight Gets the navigation bar height
- MeasureView measurement view
- GetViewWidth Gets the width of the view
- GetViewHeight Gets the height of the view
/** ** id check ** According to the provisions of national Standard GB 11643-1999 of the People's Republic of China on citizenship number, citizenship number is a combination of feature code, consisting of seventeen digit body code and one digit check code. * From left to right: six-digit address code, eight-digit date of birth code, three-digit sequence code and one-digit check code. * Address code represents the administrative division code of the county (city, flag, district) where the encoding object's permanent residence is located. * Date of birth code represents the year, month and day of birth of the coding object. The year is represented by four digits, and there is no delimiter between year, month and day. * Sequence code indicates the serial number of people born in the same year, month or day within the area identified by the same address code. Odd numbers of sequential codes are assigned to males and even numbers to females. * Check code is calculated according to ISO 7064:1983.MOD 11-2 check code based on the first 17-digit word code. * Method of calculating date of birth. * The 15-digit ID code first expands the year of birth to four digits, simply by adding a 19 or 18, so that everyone born between 1800 and 1999 is included; $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ * below is the regular expression: * date of birth / 1800-2099 (20) 18 19 | |? \ d {2} [1-9] | (0. 1 [012]) (0 | [1-9] [12] \ | 3 d [01]) / * id regular expressions / ^ 1-9] [\ d {5} ((1 [89] 20) | \ d {2}) (0 [1-9] | 1 [2-0]) (0 [1-9] | [12] \ | 3 d [01]) \ d {3} [\ dx] $/ I * 15 check rule 6 bit address code + 6 + 3 serial number of date of birth * 18 validation rules 6 + 8 bits of date of birth, address coding three serial number + 1 a parity bit * parity rule formula: ∑ * Wi (ai) (mod)..................................................................... (1) * In Formula (1) : * I ---- indicates the serial number of the number character, including the parity code, from left to right. * ai---- represents the number character value in position I; * Wi---- shows the weighting factor at position I, which is calculated according to the formula Wi=2^(n-1) (mod 11). * i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 * Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1 *
* * @author yoojia. Chen ([email protected]) * @version version 2015-05-21 * @since 2.0 */Copy the code
This library references code from many networks, and we would like to extend our sincere thanks to those who contribute so selflessly.
License
Copyright (C) 2016 [email protected]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copy the code