README of English
In order to facilitate the search, it has been roughly classified as follows:
The Activity related toActivityUtils.java-Demo
IsActivityExists: checks whether the Activity exists. Activity launchActivity: starts the Activity. GetLauncherActivity: obtains the entry ActivityCopy the code
App related -AppUtils.java-Demo
InstallApp: Installs the App (supports 6.0). InstallAppSilent: silently installs the App. UninstallApp: uninstalls the App. LaunchApp: Open the App closeApp: close the App getAppPackageName: GetAppName: Get the App name getAppIcon: Get the App icon getAppPath: GetAppVersionName: obtain the App version. GetAppVersionCode: obtain the App version. IsSystemApp: Check whether the App is a system application. GetAppSignature: Obtain the App signature getAppSignatureSHA1: Obtain the SHA1 value of the App signature isAppForeground: GetForegroundApp: obtains the name of the foreground application package. GetAppInfo: obtains App information. GetAppsInfo: obtains information about all installed appsCopy the code
Column related -BarUtils.java
HideStatusBar: Hides the status bar getStatusBarHeight: obtains the status bar height isStatusBarExists Check whether the status bar exists. GetActionBarHeight: obtains the ActionBar height. ShowNotificationBar: displays the notification barCopy the code
Clear correlation →CleanUtils.java-Demo
CleanInternalCache: cleanInternalCache cleanInternalFiles: cleanInternalFiles cleanInternalDbs: clean internal database cleanInternalDbByName: CleanInternalSP: Clear internal SP cleanExternalCache: clear external cache cleanCustomCache: clear files in the customized directoryCopy the code
Clipboard related →ClipboardUtils.java
CopyText: copyText to the clipboard getText: getText from the clipboard copyUri: copyUri to the clipboard getUri: get the uri from the clipboard copyIntent: copyIntent to the clipboard getIntent: get the intent from the clipboardCopy the code
Close correlation →CloseUtils.java
CloseIO quietly: Quietly Close the I/OCopy the code
Constant correlation →ConstUtils.java
MemoryConst: memory-related constants TimeConst: time-related constants RegexConst: regular-related constantsCopy the code
Transformation correlation →ConvertUtils.java-Test
Bytes2HexString, hexString2Bytes: byteArr interconverts with hexString chars2Bytes, bytes2Chars: Byte2Size, size2Byte: indicates the number of bytes exchanged with the unit. Byte2FitSize: indicates the number of bytes exchanged with the unit. Bytes2Bits, bits2Bytes: indicates the number of bytes exchanged with the unit. Bytes and bits interconvert input2OutputStream, output2InputStream: inputStream and outputStream interconvert inputStream2Bytes, bytes2InputStream: InputStream and byteArr interconvert outputStream2Bytes, bytes2OutputStream: InputStream2String, string2InputStream: OutputStream2String, string2OutputStream: Bitmap2Bytes: bitmap and byteArr: bitmap2bitmap: bitmap2Drawable: View2Bitmap: view to bitmap dp2px, px2dp: view2Bitmap: view to bitmap dp2px, px2dp: Px2sp: sp and PX interrotateCopy the code
Crash correlation →CrashUtils.java
GetInstance: obtains singleton init: initializes the singletonCopy the code
Device correlation →DeviceUtils.java-Demo
Root getSDKVersion: obtains the system version of the device. GetAndroidID: obtains the device. AndroidID getMacAddress: GetManufacturer: obtain the device manufacturer getModel: obtain the device model Shutdown: shutdown reboot: restart reboot2Recovery: Restart to recovery reboot2Bootloader: Restart to bootloaderCopy the code
Short correlation →EmptyUtils.java-Test
IsEmpty: checks whether the object isEmpty. IsNotEmpty: checks whether the object isNotEmptyCopy the code
Encoding decoding correlation →EncodeUtils.java-Test
UrlEncode: URL encoding urlDecode: URL decoding base64Encode, base64Encode2String: Base64 encoding base64Decode: Base64 decoding base64UrlSafeEncode: Base64URL security encoding htmlEncode: Html encoding htmlDecode: Html decodingCopy the code
Encryption and decryption related →EncryptUtils.java-Test
EncryptMD2, encryptMD2ToString: MD2 encryptMD5, encryptMD5ToString: MD5 encryptMD5File, encryptMD5File2String: EncryptSHA224 encryptSHA224ToString MD5 encryptSHA1, encryptSHA1ToString: SHA1 encryptSHA224, encryptSHA224ToString: EncryptSHA256, encryptSHA256ToString: SHA256 encryptSHA384, encryptSHA384ToString: SHA256 encryptSHA384, encryptSHA384ToString: EncryptSHA512, encryptSHA512ToString: encryptHmacMD5, encryptHmacMD5ToString: HmacMD5 encryption encryptHmacSHA1 encryptHmacSHA1ToString: HmacSHA1 encryption encryptHmacSHA224, encryptHmacSHA224ToString: HmacSHA224 encryption encryptHmacSHA256 encryptHmacSHA256ToString: HmacSHA256 encryption encryptHmacSHA384, encryptHmacSHA384ToString: HmacSHA384 encryption encryptHmacSHA512 encryptHmacSHA512ToString: HmacSHA512 encryptDES, encryptDES2HexString, encryptDES2Base64: DES encrypts decryptDES, decryptHexStringDES, decryptBase64DES: DES encrypt3DES, encrypt3DES2HexString, encrypt3DES2Base64: Decrypt3DES encryption decrypt3DES, decryptHexString3DES, decryptBase64_3DES: EncryptAES, encryptAES2HexString, encryptAES2Base64: AES encryptAES decryptAES, decryptHexStringAES, decryptBase64AES: AES decryptionCopy the code
File correlation →FileUtils.java-Test
IsFileExists: determines whether a file exists rename: renames a file isDir: determines whether a file exists isFile: determines whether a file exists createOrExistsDir: specifies whether a file exists. Whether directory exists, there is no judgment whether to create successful createOrExistsFile: to determine whether a file exists, does not exist, it determine whether create createFileByDeleteOldFile success: Check whether the file exists and delete the file before creating it. CopyDir: copy the directory. CopyFile: copy the file. Delete files. ListFilesInDir: Obtain all files in the directory. ListFilesInDir: Obtain all files in the directory, including subdirectories. Obtain all files with suffix suffix in the directory listFilesInDirWithFilter: Obtain all files with suffix suffix in the directory, including subdirectory listFilesInDirWithFilter: ListFilesInDirWithFilter: Obtains all filter-compliant files in the directory, including the subdirectory searchFileInDir: WriteFileFromIS: writes input streams to files. WriteFileFromString: writes strings to files. GetFileCharsetSimple: GetFileLines: Obtain the number of lines of a file. ReadFile2List: obtain the number of lines of a file. ReadFile2SB: Obtain the number of lines of a file. GetFileMD5, getFileMD5ToString: obtains the MD5 verification code of the file. GetDirName: obtains the longest directory based on the full path. GetFileName: obtains the longest directory based on the full path. GetFileNameNoExtension: the file name without the extension name is obtained from the full path. GetFileExtension: the file name is obtained from the full pathCopy the code
Handler associated -HandlerUtils.java-Demo
HandlerHolder: Use required readingCopy the code
Pictures related →ImageUtils.java-Demo
Bitmap2Bytes, bytes2Bitmap: drawable2Bitmap, bitmap2Drawable: Drawable: drawable: drawable: bytes2Drawable: Drawable: byteArr: drawable: Drawable: byteArr: drawable: getBitmap: obtain bitmap scale: scale the image clip: Skew: the image is rotated skew: the image is rotated getRotateDegree: the image is rotated toRound: the image is rounded toRoundCorner: the image is rounded fastBlur: the image is rotated How to add a color to the frame and add it to the addReflection AddImageWatermark: addImageWatermark toAlpha: convert toAlpha bitmap toGray: convert to grayscale image save: save the image isImage: Determine whether the file is a picture based on the file name. GetImageType: obtain the image type. CompressByScale: compress the file by scalingCopy the code
Intention correlation →IntentUtils.java
GetInstallAppIntent: Obtains the intent to install the App (supports 6.0). Gettuninstallappintent: Obtains the intent to uninstall the App. GetLaunchAppIntent: For open the App intention getAppDetailsSettingsIntent: for specific Settings App intention getShareTextIntent: share access to the intention of the text getShareImageIntent: For share photos intention getComponentIntent: access to the intentions of other application components getShutdownIntent: get off the intention of the getCaptureIntent: access to the intention of the photoCopy the code
Keyboard related →KeyboardUtils.java-Demo
HideSoftInput: dynamic hide the soft keyboard clickBlankArea2HideSoftInput: click on the blank area to hide the screen soft keyboard showSoftInput: dynamic display soft keyboard toggleSoftInput: Switch the keyboard display stateCopy the code
Positioning correlation →LocationUtils.java-Demo
IsGpsEnabled: checks whether Gps is available isLocationEnabled: checks whether Gps is available openGpsSettings: opens the Gps setting page register: registers unregister: GetCountryName: Obtains the locality based on the longitude and latitude getLocality: Obtains the locality based on the longitude and latitude getStreet: Obtains the locality based on the longitude and latitudeCopy the code
Log correlation →LogUtils.java-Test
Init: initialization function getBuilder: Obtain LogUtils Builder V: Verbose log D: Debug log I: Info log W: Warn log e: Error logCopy the code
Network correlation →NetworkUtils.java-Demo
IsConnected: checks whether the network isConnected. IsAvailableByPing: checks whether the network is available. GetDataEnabled: Check whether mobile data is enabled setDataEnabled: enable or disable mobile data is4G: check whether the network is4G getWifiEnabled: check whether wifi is enabled setWifiEnabled: IsWifiConnected: Connected to a wifi interface isWifiAvailable: Connected to a wifi interface getNetworkOperatorName GetNetworkType: obtains the current network type. GetIPAddress: obtains the IP address. GetDomainAddress: obtains the IP address of the domain nameCopy the code
Mobile related →PhoneUtils.java-Demo
GetIMEI: obtain the IMEI code. GetIMSI: obtain the IMSI code. GetPhoneType: obtain the mobile terminal type. Check whether the SIM card is ready. GetSimOperatorName, getSimOperatorByMnc: Obtains the operator name of the SIM card. GetPhoneStatus: obtains the mobile phone status information. Dial phoneNumber sendSms: jump to the page for sending SHORT messages. SendSmsSilent: send short messages. GetAllContactInfo: obtain mobile phone contacts. Tap a contact to obtain the phone number. GetAllSMS: Obtain a mobile phone short message and save it in XMLCopy the code
Pinyin related →PinyinUtils.java-Test
GetPinyinFirstLetter: Get the first letter of Chinese character ccs2Pinyin: Transfer Chinese character to pinyinCopy the code
Process correlation →ProcessUtils.java-Demo
GetForegroundProcessName: access to the foreground thread package name cleanAllBackgroundProcesses, cleanBackgroundProcesses: clean up the background service processCopy the code
Canonical correlation →RegexUtils.java-Test
IsMobileSimple: verify mobile phone number (simple) isMobileExact: verify mobile phone number (exact) isTel: verify phone number isIDCard15: verify ID card number 15-digit isIDCard18: verify mobile phone number Verify ID card number 18-bit isEmail: verify email address isURL: verify URL isZh: verify Chinese characters isUsername: verify user name isDate: verify date verification in YYYY-MM-DD format, with even leap year taken into account isIP: GetMatches: The portion of the matched regula ti on is obtained. Gettreplacefirst: The first part of the matched regula ti on is replaced. GetReplaceAll: Replace all portions of the re matchCopy the code
Screen correlation →ScreenUtils.java
GetScreenWidth: Get the width of the screen (unit: px) getScreenHeight: Get the height of the screen (unit: px) IsLandscape: determine whether the screen isPortrait isPortrait: determine whether the screen isPortrait getScreenRotation: get the screen rotation Angle captureWithStatusBar: Obtain the current screen shot, including the status bar captureWithoutStatusBar: obtain the current screen shot, excluding the status bar isScreenLock: determine whether to lock the screenCopy the code
SD card related →SDCardUtils.java-Demo
GetSDCardPath: path to obtain the SD card getDataPath: path to obtain the Data of the SD card getFreeSpace: calculates the remaining space of the SD card getSDCardInfo: Obtain SD card informationCopy the code
Service related →ServiceUtils.java
IsServiceRunning: Checks whether the service runs stopService: stops the serviceCopy the code
Shell related -ShellUtils.java
ExecCmd: Indicates whether to run the command under rootCopy the code
Size correlation →SizeUtils.java
Dp2px, px2dp: dp and px convert sp2px, px2sp: sp and px convert applyDimension: Measureviewmeasureviewmeasuredwidth getMeasuredHeight getMeasuredHeightCopy the code
Snackbar related -SnackbarUtils.java-Demo
ShowShortSnackbar: displays the short snackbar showLongSnackbar: displays the long snackbar showIndefiniteSnackbar: displays the user-defined duration snackbar addView: Add layout to SnackBar; dismissSnackbar displayCopy the code
SP related -SPUtils.java-Test
SPUtils: SPUtils constructor putString: SP writes String value getString: SP reads String putInt: SP writes int value getInt: SPUtils constructor putString: SP writes String value getString: SP reads String putInt: SP writes int value getInt: SP read int putLong: SP read long value getLong: SP read long putFloat: SP read float value getFloat: SP read float putBoolean: SP SP write Boolean type value getBoolean: SP read Boolean getAll: SP obtain all key/value pairs remove: SP remove key contains: SP whether the key exists clear: All data is cleared from SPCopy the code
String correlation →StringUtils.java-Test
IsEmpty: checks whether the string is null or 0 in length isSpace: checks whether the string is null or all Spaces equals: checks whether two strings are equal equalsIgnoreCase: Null2Length0: null is converted to a string of length 0. Length: Returns the length of the string. UpperFirstLetter: upperFirstLetter: upperFirstLetter: upperFirstLetter: upperFirstLetter: upperFirstLetter: Lowercase reverse: reverses the character string toDBC: converts to a half-angle character toSBC: converts to a full-angle characterCopy the code
Thread pool related →ThreadPoolUtils.java
ThreadPoolUtils: ThreadPoolUtils constructor execute: execute a given command at a future time execute a given list of commands at a future time shutDown: ShutDownNow: attempts to stop all active tasks in progress. IsShutDown: checks whether the thread pool is closed. IsTerminated: Submit: Submits a Callable task to execute submit: Submit a Runnable task to execute invokeAll, invokeAny: execute the given task schedule: Delay the execution of the Runnable command schedule: Delay executing the Callable command scheduleWithFixedRate: indicates that the Callable command is delayed and executed periodically. ScheduleWithFixedDelay: indicates that the Callable command is executed periodically at a fixed rest timeCopy the code
Time correlation →TimeUtils.java-Test
[milliseconds2int] [milliseconds2int] [milliseconds2int] [milliseconds2int] [milliseconds2int] [milliseconds2int] Date2Milliseconds date2Milliseconds: [^ ^ ^ ^ ^ ^ ^] econds2unit: Milliseconds timestamp unit conversion (unit) getIntervalTime: obtains two time differences (unit) getCurTimeMills: obtains the current timestamp getCurTimeString: GetCurTimeDate: obtains the current Date getIntervalByNow: Obtains the difference with the current time (unit: unit) isLeapYear: obtains the leap year getWeek, getWeekIndex: obtains the leap year. GetWeekOfMonth: Obtains the week in a month. GetWeekOfYear: Obtains the week in a yearCopy the code
Toast related →ToastUtils.java-Demo
Init: toast initialization showShortToastSafe: display short toast showLongToastSafe: safely and securely shows long toast showShortToast: display a short toast showLongToast: CancelToast: Cancel the toast displayCopy the code
Compression correlation →ZipUtils.java-Test
ZipFiles: decompresses files in batches zipFile: decompresses files in batches unzipFile: decompresses files in batches unzipFileByKeyword: decompresses files with keywords getFilesPath: decompresses files with keywords GetComments: obtains the linked list of comments in the compressed file. GetEntries: obtains the file object in the compressed fileCopy the code
Update the Log -update_log.md
about
- Do this sort is to make it as a small Android development dictionary, when some trivial problems, no longer face Baidu or Google to query the use of API, time-consuming and laborious, if there is here, we feel free to go; At the same time, I also hope it can grow day by day and look forward to your Star and improvement. Of course, I will always update the release version and log. In order to facilitate your import, I have uploaded it to jCenter. Many of them are also the essence of the quartet, thank you for providing, of course, the final will pass the unit test, if there is any error, please inform.
- QQ group provides discussion, 1 group: 74721490 (full) 2 group: 25206533, as for the verification problem for everyone is certainly a small case.
- My micro blog, please pay attention to it.
Gradle:
The compile 'com. Blankj: utilcode: 1.3.4'Copy the code
Proguard
-keep class com.blankj.utilcode.** { *; }
-keepclassmembers class com.blankj.utilcode.** { *; }
-dontwarn com.blankj.utilcode.**
Copy the code
Copyright 2016 Blankj
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