Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何检索设备上可用的最大堆?_Android_Heap_Android Manifest - Fatal编程技术网

Android 如何检索设备上可用的最大堆?

Android 如何检索设备上可用的最大堆?,android,heap,android-manifest,Android,Heap,Android Manifest,我有个问题。我的应用程序使用20MB内存,所以我想避免使用内存堆小于20MB的手机。 我尝试了Runtime.getRuntime.maxMemory(),但是这个函数检索到了错误的结果(SGS3上为256MB),因为我想检索单个应用程序的可用堆 我怎样才能发现它? 清单中是否有属性 谢谢。您需要的是getMemoryClass ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); 它

我有个问题。我的应用程序使用20MB内存,所以我想避免使用内存堆小于20MB的手机。 我尝试了Runtime.getRuntime.maxMemory(),但是这个函数检索到了错误的结果(SGS3上为256MB),因为我想检索单个应用程序的可用堆

我怎样才能发现它? 清单中是否有属性


谢谢。

您需要的是
getMemoryClass

 ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();

它返回当前设备的每个应用程序内存类的近似值。

您需要的是
getMemoryClass

 ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
它返回当前设备的每个应用程序内存类的近似值