Example usage for android.content ComponentCallbacks2 TRIM_MEMORY_RUNNING_LOW

List of usage examples for android.content ComponentCallbacks2 TRIM_MEMORY_RUNNING_LOW

Introduction

In this page you can find the example usage for android.content ComponentCallbacks2 TRIM_MEMORY_RUNNING_LOW.

Prototype

int TRIM_MEMORY_RUNNING_LOW

To view the source code for android.content ComponentCallbacks2 TRIM_MEMORY_RUNNING_LOW.

Click Source Link

Document

Level for #onTrimMemory(int) : the process is not an expendable background process, but the device is running low on memory.

Usage

From source file:Main.java

public static String getTrimLevelName(int level) {
    switch (level) {
    case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
        return "COMPLETE";
    case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
        return "MODERATE";
    case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
        return "BACKGROUND";
    case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
        return "UI_HIDDEN";
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
        return "RUNNING_CRITICAL";
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
        return "RUNNING_LOW";
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
        return "RUNNING_MODERATE";
    default:/*  w  w  w .java 2  s .  c  o m*/
        return "UNKNOWN";
    }
}

From source file:com.hippo.ehviewer.EhApplication.java

@Override
public void onTrimMemory(int level) {
    super.onTrimMemory(level);

    if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
        clearMemoryCache();/*from   ww w  .j a  v  a2 s .c o m*/
    }
}

From source file:github.popeen.dsub.service.DownloadService.java

@Override
public void onTrimMemory(int level) {
    ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this);
    if (imageLoader != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        Log.i(TAG, "Memory Trim Level: " + level);
        if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
            if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
                imageLoader.onLowMemory(0.75f);
            } else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
                imageLoader.onLowMemory(0.50f);
            } else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE) {
                imageLoader.onLowMemory(0.25f);
            }/*from  w w  w .  j  av a2s  .  c o  m*/
        } else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
            imageLoader.onLowMemory(0.25f);
        } else if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
            imageLoader.onLowMemory(0.75f);
        }
    }
}