List of usage examples for android.content ComponentCallbacks2 TRIM_MEMORY_BACKGROUND
int TRIM_MEMORY_BACKGROUND
To view the source code for android.content ComponentCallbacks2 TRIM_MEMORY_BACKGROUND.
Click Source Link
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:/*from w w w . j a v a2 s . c o m*/ return "UNKNOWN"; } }
From source file:Main.java
@SuppressLint("NewApi") public static void onTrimMemory(int level) { int count = 0; if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) { count = 10;//from ww w.j a v a 2 s .c o m if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { count = 0; } } else return; int size = 0; if (count > 0) { for (Bitmap b : placeHolders) { size += b.getByteCount(); } } int trimSize = placeHolders.size() == 0 ? 0 : ((count * size) / placeHolders.size()); Log.v(TAG, "trim image cache from " + memCache.size() + " to " + trimSize + " to reduce memory usage, max size " + memCache.maxSize()); memCache.trimToSize(trimSize); }
From source file:biz.wiz.android.wallet.service.BlockchainServiceImpl.java
@Override public void onTrimMemory(final int level) { log.info("onTrimMemory({}) called", level); if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { log.warn("low memory detected, stopping service"); stopSelf();/* www . j a v a2 s. co m*/ } }
From source file:crea.wallet.lite.service.CreativeCoinService.java
@Override public void onTrimMemory(final int level) { Log.i(TAG, String.format("onTrimMemory(%1$d) called", level)); if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { Log.d(TAG, "low memory detected, stopping service"); stopSelf();// w w w . ja va 2 s.co m } }