Java Code Examples for android.app.ActivityManager#getLargeMemoryClass()

The following examples show how to use android.app.ActivityManager#getLargeMemoryClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@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.getLargeMemoryClass() <= 64;
}
 
Example 2
Source File: BitmapCache.java    From ploggy with GNU General Public License v3.0 5 votes vote down vote up
static int calculateMemoryCacheSize(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    int memoryClass;
    if ((context.getApplicationInfo().flags & android.content.pm.ApplicationInfo.FLAG_LARGE_HEAP) != 0) {
        memoryClass = activityManager.getLargeMemoryClass();
    } else {
        memoryClass = activityManager.getMemoryClass();
    }
    // Target ~15% of the available heap.
    return 1024 * 1024 * memoryClass / 7;
}
 
Example 3
Source File: Utils.java    From picasso with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: SystemUtil.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the large memory class of the device.
 *
 * @return the memory class - the maximal available memory for the app (in MB).
 */
public static int getLargeMemoryClass() {
	ActivityManager manager =
			(ActivityManager) Application.getAppContext().getSystemService(Context.ACTIVITY_SERVICE);

	return manager.getLargeMemoryClass();
}
 
Example 5
Source File: Utils.java    From bubble with MIT License 5 votes vote down vote up
public static int getHeapSize(Context context) {
    ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
    boolean isLargeHeap = (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0;
    int memoryClass = am.getMemoryClass();
    if (isLargeHeap && Utils.isHoneycombOrLater()) {
        memoryClass = am.getLargeMemoryClass();
    }
    return 1024 * memoryClass;
}
 
Example 6
Source File: Util.java    From SoBitmap with Apache License 2.0 5 votes vote down vote up
static int getAvailableMemorySize(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    int ret = -1;
    boolean largeHeap = false;
    if (Build.VERSION.SDK_INT >= 11) {
        largeHeap = (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0;
        if (largeHeap)
            ret = am.getLargeMemoryClass() * 1024;
    }
    if (!largeHeap || Build.VERSION.SDK_INT < 11) {
        ret = am.getMemoryClass() * 1024;
    }
    return ret / 5;
}
 
Example 7
Source File: BitmapCache.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private BitmapCache() {

    // Get memory class of this device, exceeding this amount will throw an
    // OutOfMemory exception.
    final ActivityManager am = ((ActivityManager) VLCApplication.getAppContext().getSystemService(
            Context.ACTIVITY_SERVICE));
    final int memClass = AndroidUtil.isHoneycombOrLater() ? am.getLargeMemoryClass() : am.getMemoryClass();

    // Use 1/5th of the available memory for this memory cache.
    final int cacheSize = 1024 * 1024 * memClass / 5;

    Log.i(TAG, "LRUCache size set to " + cacheSize);

    mMemCache = new LruCache<String, CacheableBitmap>(cacheSize) {

        @Override
        protected int sizeOf(String key, CacheableBitmap value) {
            return value.getSize();
        }

        @Override
        protected void entryRemoved(boolean evicted, String key, CacheableBitmap oldValue, CacheableBitmap newValue) {
            if (evicted) {
                mCachedBitmaps.remove(oldValue.getReference());
                if (mReusableBitmaps != null && oldValue.get() != null && !TextUtils.equals(key, CONE_KEY) && !TextUtils.equals(key, CONE_O_KEY))
                    addReusableBitmapRef(oldValue.getReference());
            }
        }
    };

    if (AndroidUtil.isHoneycombOrLater())
        mReusableBitmaps = Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());
        mCachedBitmaps = Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());
}
 
Example 8
Source File: App.java    From greedo-layout-for-android with MIT License 5 votes vote down vote up
private int calculateMemoryCacheSize() {
    ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
    boolean largeHeap = (getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0;
    int memoryClass = am.getMemoryClass();
    if (largeHeap && SDK_INT >= HONEYCOMB) {
        memoryClass = am.getLargeMemoryClass();
    }

    // Target ~50% of the available heap.
    return 1024 * 1024 * memoryClass / 2;
}
 
Example 9
Source File: Util.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@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.getLargeMemoryClass() <= 64;
}
 
Example 10
Source File: DefaultConfigurationFactory.java    From WliveTV with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
	return am.getLargeMemoryClass();
}
 
Example 11
Source File: DefaultConfigurationFactory.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
	return am.getLargeMemoryClass();
}
 
Example 12
Source File: DefaultConfigurationFactory.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
    return am.getLargeMemoryClass();
}
 
Example 13
Source File: AMActivityManagerCompat.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@Override
public int getLargeMemoryClass(ActivityManager am) {
    return am.getLargeMemoryClass();
}
 
Example 14
Source File: DefaultConfigurationFactory.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
	return am.getLargeMemoryClass();
}
 
Example 15
Source File: Utils.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
static int getLargeMemoryClass(ActivityManager activityManager) {
  return activityManager.getLargeMemoryClass();
}
 
Example 16
Source File: Utils.java    From bubble with MIT License 4 votes vote down vote up
public static int calculateMemorySize(Context context, int percentage) {
    ActivityManager activityManager = (ActivityManager)context.getSystemService(ACTIVITY_SERVICE);
    int memoryClass = activityManager.getLargeMemoryClass();
    return 1024 * 1024 * memoryClass / percentage;
}
 
Example 17
Source File: Utils.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
static int getLargeMemoryClass(ActivityManager activityManager) {
  return activityManager.getLargeMemoryClass();
}
 
Example 18
Source File: BitmapUtils.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static int getLargeMemoryClass(ActivityManager activityManager) {
    return activityManager.getLargeMemoryClass();
}
 
Example 19
Source File: Util.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isLowMemory(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

    return (activityManager.isLowRamDevice()) || activityManager.getLargeMemoryClass() <= 64;
}
 
Example 20
Source File: DefaultConfigurationFactory.java    From candybar with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
    return am.getLargeMemoryClass();
}