关于遍历Android手机中应用的问题

来源:互联网 发布:androidargb调色板源码 编辑:程序博客网 时间:2024/05/17 02:14

先拿到应用列表

List v3 = arg5.getPackageManager().getInstalledPackages(0);

然后遍历这个列表,即可获得所以手机在安装的应用
但是有时候为了区分系统应用还后来安装的应用,可以使用如下办法:

ApplicationInfo appInfo = p.applicationInfo;    /**     * Value for {@link #flags}: if set, this application is installed in the     * device's system image.     */if((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0)    //系统程序else    //不是系统程序

其中:FLAG_SYSTEM的定义如下public static final int FLAG_SYSTEM = 1<<0;
或者是这样判断:

if((((PackageInfo)v0_1).applicationInfo.flags & 1) == 0) {    //不是系统程序} else {    //系统程序}

有时在恶意软件中,恶意代码可能需要获得安装的应用信息,同时还要区分系统和非系统的应用

0 0
原创粉丝点击