for (String name: appList) {
if(name.contains("QQ")) {
Log.v("TAG", "app name contains QQ");
appList.remove(name);
}
}
遍历List时移除List中的元素,抛出异常:
解决办法:
Log.v("TAG", "" + appList.size());
List<String> qqList = new ArrayList<String>();
for (String name: appList) {
if(name.contains("QQ")) {
Log.v("TAG", "app name contains QQ");
qqList.add(name);
}
}
for (String name: qqList) {
appList.remove(name);
}
Log.v("TAG", "" + appList.size());