-1
我想獲取安卓手機中安裝的所有應用程序的列表。通過以下代碼,我只能獲取用戶安裝的應用程序,但我也想獲得系統應用程序。獲取安卓手機中的所有應用程序
packageManager = getPackageManager();
List<PackageInfo> packageList = packageManager.getInstalledPackages(packageManager.GET_PERMISSIONS);//PackageManager.GET_META_DATA
List<PackageInfo> packageList1 = new ArrayList<PackageInfo>();
PackageManager pm = this.getPackageManager();
/*To filter out System apps*/
for(PackageInfo pi : packageList) {
boolean b = isSystemPackage(pi);
if(!b) {
packageList1.add(pi);
}
}
apkList = (ListView) findViewById(R.id.AppList);
apkList.setAdapter(new ApkAdapter(this, packageList1, packageManager));
apkList.setOnItemClickListener(this);
}
private boolean isSystemPackage(PackageInfo pkgInfo) {
return ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) ? true
: false;
}
它不給我所有的應用程序 –
輸出是什麼? – Lokesh
它只給用戶安裝的應用程序 –