Android 日常积累

  1. More than one file was found with OS independent path ‘META-INF/ASL2.0’
1
2
3
4
5
6
7
8
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
  1. ArrayList继承自AbstractList,前者实现了Serializable接口,后者未实现,所以慎用ArrayList的subList方法,它返回的是一个AbstractList。
  2. startActivityForResult()执行后onActivityResult立即执行,有可能是activity的launchmode为singletask。
  3. 对list用foreach遍历的时候,不能直接删除,可以使用迭代器。
  4. 对于HashMap,如果含有值,put相同key的时候返回上一次的值,如果没有值,返回null。
1
2
/**返回qqq*/
Map<String,String> map = new HashMap<>(); map.put("a", "qqq"); Object o1 = map.put("a","qin") ; System.out.println(o1);
1
2
返回null
Map<String,String> map = new HashMap<>(); //map.put("a", "qqq"); Object o1 = map.put("a","qin") ; System.out.println(o1);