List of usage examples for android.app ActivityManager getMemoryClass
public int getMemoryClass()
From source file:Main.java
public static int getHeapMemorySize(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return manager.getMemoryClass() * 1024 * 1024; }
From source file:Main.java
public static int getSingleAppMemeryLimit(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return activityManager.getMemoryClass(); }
From source file:Main.java
/** * Returns the Memory Class of the App or Context provided. * <br><br>/*from w ww. java 2s. c om*/ * Memory Class defines the application's maximum heap size. They are based on the * device's overall memory. The values are in base of 16. You may use * it to manage your application's memory properly. * <br><br> * Example Classes: 16, 24, 48, 64, 80, 96, 112, 128 etc... */ public static int getMemoryClass(Context context) { if (context == null) return -1; ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return am.getMemoryClass(); }
From source file:Main.java
/** * @param context//from ww w . j av a 2 s . c o m * @return */ public static int getMemoryClass(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); int heapSize = manager.getMemoryClass(); return heapSize; }
From source file:Main.java
public static long availableMemory() { final Runtime runtime = Runtime.getRuntime(); final long used = runtime.totalMemory() - runtime.freeMemory(); final ActivityManager activityManager = (ActivityManager) sContext .getSystemService(Context.ACTIVITY_SERVICE); final long total = activityManager.getMemoryClass() * 1024 * 1024; return total - used; }
From source file:Main.java
@TargetApi(VERSION_CODES.KITKAT) public static boolean isLowMemory(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return (VERSION.SDK_INT >= VERSION_CODES.KITKAT && activityManager.isLowRamDevice()) || activityManager.getMemoryClass() <= 64; }
From source file:Main.java
/** * Gets the amount of memory available to the application. * * Queries whether the largeHeap manifest flag is set. * * @param context//from w w w . j a v a 2s . co m * the application context * @return the amount of memory in bytes available to the application */ private static int getAvailableMemory(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); boolean largeHeap = (context.getApplicationInfo().flags & 1048576) != 0; int memoryClass = largeHeap ? activityManager.getLargeMemoryClass() : activityManager.getMemoryClass(); return memoryClass * 1048576; }
From source file:Main.java
static public int getLargeMemoryClass(ActivityManager am) { if (methodGetLargeMemoryClass != null) { try {/*from ww w . j a va2s . com*/ Object result = methodGetLargeMemoryClass.invoke(am); return (Integer) result; } catch (Throwable t) { t.printStackTrace(); } } return am.getMemoryClass(); }
From source file:com.bt.download.android.util.SystemUtils.java
public static int calculateMemoryCacheSize(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE); boolean largeHeap = (context.getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0; int memoryClass = am.getMemoryClass(); if (largeHeap) { memoryClass = am.getLargeMemoryClass(); }//w ww. j a v a 2 s.co m // Target ~15% of the available heap. return 1024 * 1024 * memoryClass / 7; }
From source file:com.squareup.picasso3.Utils.java
static int calculateMemoryCacheSize(Context context) { ActivityManager am = ContextCompat.getSystemService(context, ActivityManager.class); boolean largeHeap = (context.getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0; int memoryClass = largeHeap ? am.getLargeMemoryClass() : am.getMemoryClass(); // Target ~15% of the available heap. return (int) (1024L * 1024L * memoryClass / 7); }