blob: 8b9f97c1d19fbf29545432895832c8a6660842c0 [file] [log] [blame]
Dianne Hackbornc68c9132011-07-29 01:25:18 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19/**
20 * Extended {@link ComponentCallbacks} interface with a new callback for
21 * finer-grained memory management.
22 */
23public interface ComponentCallbacks2 extends ComponentCallbacks {
24
25 /**
26 * Level for {@link #onTrimMemory(int)}: the process is nearing the end
27 * of the background LRU list, and if more memory isn't found soon it will
28 * be killed.
29 */
30 static final int TRIM_MEMORY_COMPLETE = 80;
31
32 /**
33 * Level for {@link #onTrimMemory(int)}: the process is around the middle
34 * of the background LRU list; freeing memory can help the system keep
35 * other processes running later in the list for better overall performance.
36 */
37 static final int TRIM_MEMORY_MODERATE = 60;
38
39 /**
40 * Level for {@link #onTrimMemory(int)}: the process has gone on to the
41 * LRU list. This is a good opportunity to clean up resources that can
42 * efficiently and quickly be re-built if the user returns to the app.
43 */
44 static final int TRIM_MEMORY_BACKGROUND = 40;
45
46 /**
47 * Level for {@link #onTrimMemory(int)}: the process had been showing
48 * a user interface, and is no longer doing so. Large allocations with
49 * the UI should be released at this point to allow memory to be better
50 * managed.
51 */
52 static final int TRIM_MEMORY_UI_HIDDEN = 20;
53
54 /**
55 * Called when the operating system has determined that it is a good
56 * time for a process to trim unneeded memory from its process. This will
57 * happen for example when it goes in the background and there is not enough
58 * memory to keep as many background processes running as desired.
59 *
60 * @param level The context of the trim, giving a hint of the amount of
61 * trimming the application may like to perform. May be
62 * {@link #TRIM_MEMORY_COMPLETE}, {@link #TRIM_MEMORY_MODERATE},
63 * {@link #TRIM_MEMORY_BACKGROUND}, or {@link #TRIM_MEMORY_UI_HIDDEN}.
64 */
65 void onTrimMemory(int level);
66}