主要会去使用PackageManager这个类
public void getAppNames(){
PackageManager pm = this.getPackageManager();
List<PackageInfo> infoList =pm.getInstalledPackages(0);
int listSize = infoList.size();
for(int i=0;i<listSize;i++){
Log.d("Appnames", infoList.get(i).toString());
}
}
}
其实还需要去判断是否是 系统应用 如何判断系统应用呢:
public void getAppNames(){
PackageManager pm = this.getPackageManager();
List<PackageInfo> infoList =pm.getInstalledPackages(0);
for(PackageInfo packageInfo:infoList) {
//加入一个这个判断
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
Log.d("Appnames", packageInfo.packageName.toString());
}
}
}