获取手机分配给app的最大内存是多少

    private void getMaxMemoryInfo(){
        Runtime rt = Runtime.getRuntime();
        long maxMemory = rt.maxMemory();
        Log.e("1123MaxMemory:", Long.toString(maxMemory/(1024*1024)));
        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        Log.e("1123MemoryClass:", Long.toString(activityManager.getMemoryClass()));
        Log.e("1123LargeMemoryClass:", Long.toString(activityManager.getLargeMemoryClass()));
    }

 加在application里,可以获取更多内存

        android:largeHeap="true"

 

你可能感兴趣的:(获取手机分配给app的最大内存是多少)