新開啟個(gè)線程來做獲取,否則可能因?yàn)樵谥骶€程時(shí)間太長導(dǎo)致獲取不全
new Thread(new Runnable() {
@Override
public void run() {
PackageManager packageManager = getPackageManager();
List<PackageInfo> installedPackages = packageManager.getInstalledPackages(0);
for (PackageInfo packageInfo : installedPackages){
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0){
Log.v("fancy",applicationInfo.loadLabel(packageManager).toString()+"====="+applicationInfo.packageName);
}
}
}
}).start();