Skip to content

Instantly share code, notes, and snippets.

@eric-romero
Created October 28, 2021 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric-romero/d778f3ce735c79e616a980b481e19b4d to your computer and use it in GitHub Desktop.
Save eric-romero/d778f3ce735c79e616a980b481e19b4d to your computer and use it in GitHub Desktop.
class MyActivity : Activity() {
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
// Intermediate levels may be added later, so use ranged conditionals
if (level >= TRIM_MEMORY_COMPLETE ||
level in TRIM_MEMORY_RUNNING_CRITICAL until TRIM_MEMORY_UI_HIDDEN) {
imageCache.clear()
webAppMgr.onLowMemory(level)
eventLogger.reportLowMemory(level)
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment