Enable android:largeHeap in Android 4, and disable it in Android 2.3

后端 未结 5 747
粉色の甜心
粉色の甜心 2020-12-07 23:09

Currently, I have a piece of code, which is designed to run both in Android 2.3 and 4+

The code will perform much better (Where it will not have OutOfMemory exceptio

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 00:00

    Keep the android:largeHeap="true" attribute in your AndroidManifest.xml. This should be ignored for versions that don't support it. Then, to support older versions, set the heap size using the VMRuntime class (via reflection, if necessary).

    More on this topic: How to increase heap size of an android application?

提交回复
热议问题