android.content.ComponentCallbacks2 Java Examples

The following examples show how to use android.content.ComponentCallbacks2. 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: LockscreenHandler.java    From AndroidAppLockscreen with MIT License 6 votes vote down vote up
@Override
public void onTrimMemory(int i) {
    ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
    Log.d("topActivity", "CURRENT Activity ::"
            + taskInfo.get(0).topActivity.getClassName());

    if (taskInfo != null && taskInfo.size() > 0) {
        ComponentName componentInfo = taskInfo.get(0).topActivity;
        packageName = componentInfo.getPackageName();
    }
    if (!packageName.equals(getPackageName()) && i == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
        // We're in the Background
        wentToBg = true;
        Log.d(TAG, "wentToBg: " + wentToBg);
    }
}
 
Example #2
Source File: MusicControlModule.java    From react-native-music-control with MIT License 6 votes vote down vote up
@Override
public void onTrimMemory(int level) {
    switch(level) {
        // Trims memory when it reaches a moderate level and the session is inactive
        case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
            if(session.isActive()) break;

            // Trims memory when it reaches a critical level
        case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:

            Log.w(TAG, "Control resources are being removed due to system's low memory (Level: " + level + ")");
            destroy();
            break;
    }
}
 
Example #3
Source File: DownloadService.java    From Audinaut with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTrimMemory(int level) {
    ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this);
    if (imageLoader != null) {
        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);
            }
        } else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
            imageLoader.onLowMemory(0.25f);
        }
    }
}
 
Example #4
Source File: MemoryPressureListener.java    From cronet with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Used by applications to simulate a memory pressure signal. By throwing certain intent
 * actions.
 */
public static boolean handleDebugIntent(Activity activity, String action) {
    if (ACTION_LOW_MEMORY.equals(action)) {
        simulateLowMemoryPressureSignal(activity);
    } else if (ACTION_TRIM_MEMORY.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
    } else if (ACTION_TRIM_MEMORY_RUNNING_CRITICAL.equals(action)) {
        simulateTrimMemoryPressureSignal(activity,
                ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL);
    } else if (ACTION_TRIM_MEMORY_MODERATE.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_MODERATE);
    } else {
        return false;
    }

    return true;
}
 
Example #5
Source File: MemoryPressureListener.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@CalledByNative
private static void registerSystemCallback() {
    ContextUtils.getApplicationContext().registerComponentCallbacks(
            new ComponentCallbacks2() {
                @Override
                public void onTrimMemory(int level) {
                    maybeNotifyMemoryPresure(level);
                }

                @Override
                public void onLowMemory() {
                    nativeOnMemoryPressure(MemoryPressureLevel.CRITICAL);
                }

                @Override
                public void onConfigurationChanged(Configuration configuration) {
                }
            });
}
 
Example #6
Source File: MemoryPressureListener.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Used by applications to simulate a memory pressure signal. By throwing certain intent
 * actions.
 */
public static boolean handleDebugIntent(Activity activity, String action) {
    if (ACTION_LOW_MEMORY.equals(action)) {
        simulateLowMemoryPressureSignal(activity);
    } else if (ACTION_TRIM_MEMORY.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
    } else if (ACTION_TRIM_MEMORY_RUNNING_CRITICAL.equals(action)) {
        simulateTrimMemoryPressureSignal(activity,
                ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL);
    } else if (ACTION_TRIM_MEMORY_MODERATE.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_MODERATE);
    } else {
        return false;
    }

    return true;
}
 
Example #7
Source File: MemoryMonitorAndroid.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Register ComponentCallbacks2 to receive memory pressure signals.
 *
 */
@CalledByNative
private static void registerComponentCallbacks() {
    sCallbacks = new ComponentCallbacks2() {
            @Override
            public void onTrimMemory(int level) {
                if (level != ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
                    nativeOnTrimMemory(level);
                }
            }
            @Override
            public void onLowMemory() {
                // Don't support old onLowMemory().
            }
            @Override
            public void onConfigurationChanged(Configuration config) {
            }
        };
    ContextUtils.getApplicationContext().registerComponentCallbacks(sCallbacks);
}
 
Example #8
Source File: VRBrowserActivity.java    From FirefoxReality with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onTrimMemory(int level) {

    // Determine which lifecycle or system event was raised.
    switch (level) {

        case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
        case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
        case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
        case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
            // Curently ignore these levels. They are handled somewhere else.
            break;
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
            // It looks like these come in all at the same time so just always suspend inactive Sessions.
            Log.d(LOGTAG, "Memory pressure, suspending inactive sessions.");
            SessionStore.get().suspendAllInactiveSessions();
            break;
        default:
            Log.e(LOGTAG, "onTrimMemory unknown level: " + level);
            break;
    }
}
 
Example #9
Source File: DownloadService.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
@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);
			}
		} else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
			imageLoader.onLowMemory(0.25f);
		} else if(level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
			imageLoader.onLowMemory(0.75f);
		}
	}
}
 
Example #10
Source File: FirebaseAppTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testRemovedBackgroundStateChangeCallbacksDontFire() {
  FirebaseApp firebaseApp = FirebaseApp.initializeApp(targetContext, OPTIONS, "myApp");
  final AtomicInteger callbackCount = new AtomicInteger();
  FirebaseApp.BackgroundStateChangeListener listener =
      background -> callbackCount.incrementAndGet();
  firebaseApp.addBackgroundStateChangeListener(listener);
  firebaseApp.removeBackgroundStateChangeListener(listener);

  // App moves to the background.
  backgroundDetector.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);

  // App moves to the foreground.
  backgroundDetector.onActivityResumed(null);

  assertThat(callbackCount.get()).isEqualTo(0);
}
 
Example #11
Source File: FirebaseAppTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testBackgroundStateChangeCallbacks() {
  FirebaseApp firebaseApp = FirebaseApp.initializeApp(targetContext, OPTIONS, "myApp");
  firebaseApp.setAutomaticResourceManagementEnabled(true);
  final AtomicBoolean backgroundState = new AtomicBoolean();
  final AtomicInteger callbackCount = new AtomicInteger();
  firebaseApp.addBackgroundStateChangeListener(
      background -> {
        backgroundState.set(background);
        callbackCount.incrementAndGet();
      });
  assertThat(callbackCount.get()).isEqualTo(0);

  // App moves to the background.
  backgroundDetector.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
  assertThat(callbackCount.get()).isEqualTo(1);
  assertThat(backgroundState.get()).isTrue();

  // App moves to the foreground.
  backgroundDetector.onActivityResumed(null);
  assertThat(callbackCount.get()).isEqualTo(2);
  assertThat(backgroundState.get()).isFalse();
}
 
Example #12
Source File: DefaultImageCache.java    From CrossBow with Apache License 2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void trimMemory(int level) {

    if(level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        emptyCache(); //dump the cache
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE){
        trimCache(0.5f); // trim to half the max size
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND){
        trimCache(0.7f); // trim to one seventh max size
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL){
        trimCache(0.2f); // trim to one fifth max size
    }
}
 
Example #13
Source File: WindowManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void trimMemory(int level) {
    if (ThreadedRenderer.isAvailable()) {
        if (shouldDestroyEglContext(level)) {
            // Destroy all hardware surfaces and resources associated to
            // known windows
            synchronized (mLock) {
                for (int i = mRoots.size() - 1; i >= 0; --i) {
                    mRoots.get(i).destroyHardwareResources();
                }
            }
            // Force a full memory flush
            level = ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
        }

        ThreadedRenderer.trimMemory(level);

        if (ThreadedRenderer.sTrimForeground) {
            doTrimForeground();
        }
    }
}
 
Example #14
Source File: WindowManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void doTrimForeground() {
    boolean hasVisibleWindows = false;
    synchronized (mLock) {
        for (int i = mRoots.size() - 1; i >= 0; --i) {
            final ViewRootImpl root = mRoots.get(i);
            if (root.mView != null && root.getHostVisibility() == View.VISIBLE
                    && root.mAttachInfo.mThreadedRenderer != null) {
                hasVisibleWindows = true;
            } else {
                root.destroyHardwareResources();
            }
        }
    }
    if (!hasVisibleWindows) {
        ThreadedRenderer.trimMemory(
                ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
    }
}
 
Example #15
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
final void handleLowMemory() {
    ArrayList<ComponentCallbacks2> callbacks;

    synchronized (mPackages) {
        callbacks = collectComponentCallbacksLocked(true, null);
    }

    final int N = callbacks.size();
    for (int i=0; i<N; i++) {
        callbacks.get(i).onLowMemory();
    }

    // Ask SQLite to free up as much memory as it can, mostly from its page caches.
    if (Process.myUid() != Process.SYSTEM_UID) {
        int sqliteReleased = SQLiteDatabase.releaseMemory();
        EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased);
    }

    // Ask graphics to free up as much as possible (font/image caches)
    Canvas.freeCaches();

    // Ask text layout engine to free also as much as possible
    Canvas.freeTextLayoutCaches();

    BinderInternal.forceGc("mem");
}
 
Example #16
Source File: SketchUtils.java    From sketch with Apache License 2.0 6 votes vote down vote up
/**
 * 获取修剪级别的名称
 */
@NonNull
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:
            return "UNKNOWN";
    }
}
 
Example #17
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@CalledByNative
private static void registerSystemCallback(Context context) {
    context.registerComponentCallbacks(
        new ComponentCallbacks2() {
              @Override
              public void onTrimMemory(int level) {
                  maybeNotifyMemoryPresure(level);
              }

              @Override
              public void onLowMemory() {
                  nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
              }

              @Override
              public void onConfigurationChanged(Configuration configuration) {
              }
        });
}
 
Example #18
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Used by applications to simulate a memory pressure signal. By throwing certain intent
 * actions.
 */
public static boolean handleDebugIntent(Activity activity, String action) {
    if (ACTION_LOW_MEMORY.equals(action)) {
        simulateLowMemoryPressureSignal(activity);
    } else if (ACTION_TRIM_MEMORY.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
    } else if (ACTION_TRIM_MEMORY_RUNNING_CRITICAL.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_MODERATE);
    } else if (ACTION_TRIM_MEMORY_MODERATE.equals(action)) {
        simulateTrimMemoryPressureSignal(activity,
                ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL);
    } else {
        return false;
    }

    return true;
}
 
Example #19
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
final void handleLowMemory() {
    ArrayList<ComponentCallbacks2> callbacks;

    synchronized (mPackages) {
        callbacks = collectComponentCallbacksLocked(true, null);
    }

    final int N = callbacks.size();
    for (int i=0; i<N; i++) {
        callbacks.get(i).onLowMemory();
    }

    // Ask SQLite to free up as much memory as it can, mostly from its page caches.
    if (Process.myUid() != Process.SYSTEM_UID) {
        int sqliteReleased = SQLiteDatabase.releaseMemory();
        EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased);
    }

    // Ask graphics to free up as much as possible (font/image caches)
    Canvas.freeCaches();

    BinderInternal.forceGc("mem");
}
 
Example #20
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@CalledByNative
private static void registerSystemCallback(Context context) {
    context.registerComponentCallbacks(
        new ComponentCallbacks2() {
              @Override
              public void onTrimMemory(int level) {
                  maybeNotifyMemoryPresure(level);
              }

              @Override
              public void onLowMemory() {
                  nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
              }

              @Override
              public void onConfigurationChanged(Configuration configuration) {
              }
        });
}
 
Example #21
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Used by applications to simulate a memory pressure signal. By throwing certain intent
 * actions.
 */
public static boolean handleDebugIntent(Activity activity, String action) {
    if (ACTION_LOW_MEMORY.equals(action)) {
        simulateLowMemoryPressureSignal(activity);
    } else if (ACTION_TRIM_MEMORY.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
    } else if (ACTION_TRIM_MEMORY_RUNNING_CRITICAL.equals(action)) {
        simulateTrimMemoryPressureSignal(activity, ComponentCallbacks2.TRIM_MEMORY_MODERATE);
    } else if (ACTION_TRIM_MEMORY_MODERATE.equals(action)) {
        simulateTrimMemoryPressureSignal(activity,
                ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL);
    } else {
        return false;
    }

    return true;
}
 
Example #22
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
final void handleTrimMemory(int level) {
    if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Trimming memory to level: " + level);

    final WindowManagerImpl windowManager = WindowManagerImpl.getDefault();
    windowManager.startTrimMemory(level);

    ArrayList<ComponentCallbacks2> callbacks;
    synchronized (mPackages) {
        callbacks = collectComponentCallbacksLocked(true, null);
    }

    final int N = callbacks.size();
    for (int i = 0; i < N; i++) {
        callbacks.get(i).onTrimMemory(level);
    }

    windowManager.endTrimMemory();        
}
 
Example #23
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void maybeNotifyMemoryPresure(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND ||
            level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
        // dispatches actionable memory pressure signals to native.
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERATE);
    }
}
 
Example #24
Source File: DefaultAppStateRecognizerSetupTest.java    From RxAppState with MIT License 5 votes vote down vote up
@Test
public void registersCallbacks() {
  recognizer.start();

  verify(mockApplication).registerActivityLifecycleCallbacks(any(ActivityLifecycleCallbacks.class));
  verify(mockApplication).registerComponentCallbacks(any(ComponentCallbacks2.class));
  verify(mockApplication).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
}
 
Example #25
Source File: DefaultAppStateRecognizerSetupTest.java    From RxAppState with MIT License 5 votes vote down vote up
@Test
public void unregistersCallbacks() {
  recognizer.start();
  recognizer.stop();

  verify(mockApplication).unregisterActivityLifecycleCallbacks(any(ActivityLifecycleCallbacks.class));
  verify(mockApplication).unregisterComponentCallbacks(any(ComponentCallbacks2.class));
  verify(mockApplication).unregisterReceiver(any(BroadcastReceiver.class));
}
 
Example #26
Source File: App.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onTrimMemory(int level) {
	super.onTrimMemory(level);
	if(Constants.DEBUG) Log.w("App", "onTrimMemory");
	if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
		BitmapUtil.cleanMemCache();  //清除图片内存的中缓存
    }
}
 
Example #27
Source File: Launcher.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void onTrimMemory(int level) {
	super.onTrimMemory(level);
	if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
		mAppsCustomizeLayout.onTrimMemory();
	}
}
 
Example #28
Source File: MemoryPressureListener.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public static void maybeNotifyMemoryPresure(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevel.CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND
            || level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
        // dispatches actionable memory pressure signals to native.
        nativeOnMemoryPressure(MemoryPressureLevel.MODERATE);
    }
}
 
Example #29
Source File: MemoryPressureListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void maybeNotifyMemoryPresure(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND ||
            level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
        // dispatches actionable memory pressure signals to native.
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERATE);
    }
}
 
Example #30
Source File: MainActivity.java    From ello-android with MIT License 5 votes vote down vote up
@Override
public void onTrimMemory(int level) {
    super.onTrimMemory(level);
    if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
        shouldReload = true;
    }
}