1. android:installLocation=" auto | internalOnly | preferExternal"
上次恰巧碰到手機內存不足的問題,後面一查,發現手機上的app默認都安裝到內存中了。只要將app移到存儲上,但發現其中有些竟然不能移,原來是和這個屬性有關。
auto:默認安裝到內存中,但可以手動移至存儲。
internalOnly:只能安裝到內存中。
preferExternal:安裝到存儲中。
默認是internalOnly,如果未設置這個屬性,那麼app就不能移動到存儲上了。
2. android:largeHeap="true"
既然扯到這個屬性了,那就寫一點有關android內存的東西吧。the baseline Android memory class is 16 (which happens to be the Java heap limit of those devices); some device with more memory may return 24 or even higher numbers.也就說android程序的內存一般在16M左右,當然可能24M或24M+。android內存分爲兩不部分:native和dalvik。兩部分加起來不能超過設置的最大值,那麼最大值在哪裏設置的呢。不同機器的最大值設定各有不同,在/system/build.pro文件中。
獲取當前機器的可用內存方法:
int availableMem = ((ActivityManager)getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
long availableMem2 = Runtime.getRuntime().maxMemory();
前者單位是M,後者是byte。如MX2中的值:
dalvik.vm.heapgrowthlimit=192m
dalvik.vm.heapsize=512m
heapgrowthlimit就是app的最大內存值,heapsize麼就是當android:largeHeap="true"所能用的最大值了。