blob: b96c8d38f99dbe5a6e2cbdf89d167a01270a3b4f [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
19import android.content.res.Configuration;
20
21/**
22 * The set of callback APIs that are common to all application components
23 * ({@link android.app.Activity}, {@link android.app.Service},
24 * {@link ContentProvider}, and {@link android.app.Application}).
Scott Maina23fd882013-08-15 13:53:31 -070025 *
26 * <p class="note"><strong>Note:</strong> You should also implement the {@link
27 * ComponentCallbacks2} interface, which provides the {@link
28 * ComponentCallbacks2#onTrimMemory} callback to help your app manage its memory usage more
29 * effectively.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030 */
31public interface ComponentCallbacks {
32 /**
33 * Called by the system when the device configuration changes while your
34 * component is running. Note that, unlike activities, other components
35 * are never restarted when a configuration changes: they must always deal
36 * with the results of the change, such as by re-retrieving resources.
Scott Maina23fd882013-08-15 13:53:31 -070037 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 * <p>At the time that this function has been called, your Resources
39 * object will have been updated to return resource values matching the
40 * new configuration.
Scott Maina23fd882013-08-15 13:53:31 -070041 *
42 * <p>For more information, read <a href="{@docRoot}guide/topics/resources/runtime-changes.html"
43 * >Handling Runtime Changes</a>.
44 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 * @param newConfig The new device configuration.
46 */
47 void onConfigurationChanged(Configuration newConfig);
Scott Maina23fd882013-08-15 13:53:31 -070048
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049 /**
50 * This is called when the overall system is running low on memory, and
Scott Maina23fd882013-08-15 13:53:31 -070051 * actively running processes should trim their memory usage. While
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 * the exact point at which this will be called is not defined, generally
Scott Maina23fd882013-08-15 13:53:31 -070053 * it will happen when all background process have been killed.
54 * That is, before reaching the point of killing processes hosting
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 * service and foreground UI that we would like to avoid killing.
Scott Maina23fd882013-08-15 13:53:31 -070056 *
57 * <p>You should implement this method to release
58 * any caches or other unnecessary resources you may be holding on to.
59 * The system will perform a garbage collection for you after returning from this method.
60 * <p>Preferably, you should implement {@link ComponentCallbacks2#onTrimMemory} from
61 * {@link ComponentCallbacks2} to incrementally unload your resources based on various
62 * levels of memory demands. That API is available for API level 14 and higher, so you should
63 * only use this {@link #onLowMemory} method as a fallback for older versions, which can be
64 * treated the same as {@link ComponentCallbacks2#onTrimMemory} with the {@link
65 * ComponentCallbacks2#TRIM_MEMORY_COMPLETE} level.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066 */
67 void onLowMemory();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068}