首页 > 代码库 > 检查或遍历android手机应程
检查或遍历android手机应程
检查android手机中是否存在某应程
public boolean checkApp(String packageName) {
if (packageName == null || "".equals(packageName))
return false;
try {
ApplicationInfo info = getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
遍历android手机中的所有应用
private void foreachSoft() {
PackageManager packageMgr = getPackageManager();
List<PackageInfo> list = packageMgr.getInstalledPackages(0);
for (int i = 0; i < list.size(); i++) {
PackageInfo info = list.get(i);
String temp = info.packageName;
Log.i("lyf", temp);
}
}