先拿到应用列表
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 {
//系统程序
}
有时在恶意软件中,恶意代码可能需要获得安装的应用信息,同时还要区分系统和非系统的应用