目前包括 HttpUtils、DownloadManagerPro、Safe.ijiami、ShellUtils、PackageUtils、PreferencesUtils、JSONUtils、FileUtils、ResourceUtils、StringUtils、ParcelUtils、RandomUtils、ArrayUtils、ImageUtils、ListUtils、MapUtils、ObjectUtils、SerializeUtils、SystemUtils、TimeUtils。

1、HttpUtils

Http网络工具类,主要包括httpGet、httpPost以及http参数相关方法,以httpGet为例:

static HttpResponse httpGet(HttpRequestrequest)

static HttpResponse httpGet(java.lang.StringhttpUrl)

static String httpGetString(String httpUrl)

包含以上三个方法,默认使用gzip压缩,使用bufferedReader提高读取速度。

HttpRequest中可以设置url、timeout、userAgent等其他http参数

HttpResponse中可以获取返回内容、http响应码、http过期时间(Cache-Control的max-age和expires)等

前两个方法可以进行高级参数设置及丰富内容返回,第三个方法可以简单的传入url获取返回内容,httpPost类似。更详细的设置可以直接使用HttpURLConnection或apache的HttpClient。

2、DownloadManagerPro

Android系统下载管理DownloadManager增强方法,可用于包括获取下载相关信息,如:

getStatusById(long) 得到下载状态

getDownloadBytes(long) 得到下载进度信息

getBytesAndStatus(long) 得到下载进度信息和状态

getFileName(long) 得到下载文件路径

getUri(long) 得到下载uri

getReason(long) 得到下载失败或暂停原因

getPausedReason(long) 得到下载暂停原因

getErrorCode(long) 得到下载错误码

3、Safe.ijiami

Android漏洞检测工具,在线上传Androidapk,检测apk开发过程中产生的一些易被黑客利用、攻击的漏洞,根据存在的漏洞提出相应的解决方案,一键生成详细的分析报告,让Android开发者可以一目了然的知道自己的Android应用存在的漏洞并及时采取措施保护起来。

4、ShellUtils

Android Shell工具类,可用于检查系统root权限,并在shell或root用户下执行shell命令。如:checkRootPermission()检查root权限execCommand(String[] commands, boolean isRoot, booleanisNeedResultMsg) shell环境执行命令,第二个参数表示是否root权限执行execCommand(String command, boolean isRoot) shell环境执行命令

5、PackageUtils

Android包相关工具类,可用于(root)安装应用、(root)卸载应用、判断是否系统应用等,

如:install(Context, String) 安装应用,如果是系统应用或已经root,则静默安装,否则一般安装uninstall(Context,String) 卸载应用,如果是系统应用或已经root,则静默卸载,否则一般卸载isSystemApplication(Context, String) 判断应用是否为系统应用

6、PreferencesUtils

Android SharedPreferences相关工具类,可用于方便的向SharedPreferences中读取和写入相关类型数据, 如:putString(Context,String, String) 保存string类型数据

putInt(Context, String, int) 保存int类型数据

getString(Context, String) 获取string类型数据

getInt(Context, String) 获取int类型数据

可通过修改PREFERENCE_NAME变量修改preference name

7、JSONUtils

JSONUtils工具类,可用于方便的向Json中读取和写入相关类型数据,如:

String getString(JSONObject jsonObject,String key, String defaultValue) 得到string类型value

String getString(String jsonData, Stringkey, String defaultValue) 得到string类型value

表示从json中读取某个String类型key的值

getMap(JSONObject jsonObject, String key) 得到map

getMap(String jsonData, String key) 得到map

表示从json中读取某个Map类型key的值

8、FileUtils

文件工具类,可用于读写文件及对文件进行操作。如:

readFile(String filePath) 读文件

writeFile(String filePath, String content,boolean append) 写文件

getFileSize(String path) 得到文件大小

deleteFile(String path) 删除文件

9、ResourceUtils

Android Resource工具类,可用于从android资源目录的raw和assets目录读取内容,如:

geFileFromAssets(Context context, StringfileName) 得到assets目录下某个文件内容

geFileFromRaw(Context context, int resId) 得到raw目录下某个文件内容

10、StringUtils

String工具类,可用于常见字符串操作,如:

isEmpty(String str) 判断字符串是否为空或长度为0

isBlank(String str) 判断字符串是否为空或长度为0或由空格组成

utf8Encode(String str) 以utf-8格式编码

capitalizeFirstLetter(String str) 首字母大写

11、ParcelUtils

Android Parcel工具类,可用于从parcel读取或写入特殊类型数据,如:

readBoolean(Parcel in) 从pacel中读取boolean类型数据

readHashMap(Parcel in, ClassLoader loader) 从pacel中读取map类型数据

writeBoolean(boolean b, Parcel out) 向parcel中写入boolean类型数据

writeHashMap(Map map, Parcel out, intflags) 向parcel中写入map类型数据

12、RandomUtils

随机数工具类,可用于获取固定大小固定字符内的随机数,如:

getRandom(char[] sourceChar, int length) 生成随机字符串,所有字符均在某个字符串内

getRandomNumbers(int length) 生成随机数字

13、ArrayUtils

数组工具类,可用于数组常用操作,如:

isEmpty(V[] sourceArray) 判断数组是否为空或长度为0

getLast(V[] sourceArray, V value, VdefaultValue, boolean isCircle) 得到数组中某个元素前一个元素,isCircle表示是否循环

getNext(V[] sourceArray, V value, VdefaultValue, boolean isCircle) 得到数组中某个元素下一个元素,isCircle表示是否循环

14、ImageUtils

图片工具类,可用于Bitmap, byte array, Drawable之间进行转换以及图片缩放,目前功能薄弱,后面会进行增强。如:

bitmapToDrawable(Bitmap b) bimap转换为drawable

drawableToBitmap(Drawable d) drawable转换为bitmap

drawableToByte(Drawable d) drawable转换为byte

scaleImage(Bitmap org, float scaleWidth,float scaleHeight) 缩放图片

15、ListUtils

List工具类,可用于List常用操作,如:

isEmpty(List sourceList) 判断List是否为空或长度为0

join(List list, String separator) List转换为字符串,并以固定分隔符分割

addDistinctEntry(List sourceList, V entry) 向list中添加不重复元素

16、MapUtils

Map工具类,可用于Map常用操作,如:

isEmpty(Map sourceMap) 判断map是否为空或长度为0

parseKeyAndValueToMap(String source, StringkeyAndValueSeparator, String keyAndValuePairSeparator, boolean ignoreSpace) 字符串解析为map

toJson(Map map) map转换为json格式

17、ObjectUtils

Object工具类,可用于Object常用操作,如:

isEquals(Object actual, Object expected) 比较两个对象是否相等

compare(V v1, V v2) 比较两个对象大小

transformIntArray(int[] source) Integer 数组转换为int数组

18、SerializeUtils

序列化工具类,可用于序列化对象到文件或从文件反序列化对象,如:

deserialization(String filePath) 从文件反序列化对象

serialization(String filePath, Object obj) 序列化对象到文件

19、SystemUtils

系统信息工具类,可用于得到线程池合适的大小,目前功能薄弱,后面会进行增强。如:

getDefaultThreadPoolSize() 得到跟系统配置相符的线程池大小

20、TimeUtils

时间工具类,可用于时间相关操作,如:

getCurrentTimeInLong() 得到当前时间

getTime(long timeInMillis, SimpleDateFormatdateFormat) 将long转换为固定格式时间字符串