19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* 29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project 39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License. 69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at 79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and 149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License. 159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.content; 189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.res.Configuration; 209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/** 229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The set of callback APIs that are common to all application components 239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * ({@link android.app.Activity}, {@link android.app.Service}, 249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link ContentProvider}, and {@link android.app.Application}). 25a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * 26a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * <p class="note"><strong>Note:</strong> You should also implement the {@link 27a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * ComponentCallbacks2} interface, which provides the {@link 28a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * ComponentCallbacks2#onTrimMemory} callback to help your app manage its memory usage more 29a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * effectively.</p> 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic interface ComponentCallbacks { 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Called by the system when the device configuration changes while your 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * component is running. Note that, unlike activities, other components 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * are never restarted when a configuration changes: they must always deal 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * with the results of the change, such as by re-retrieving resources. 37a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>At the time that this function has been called, your Resources 399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * object will have been updated to return resource values matching the 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * new configuration. 41a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * 42a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * <p>For more information, read <a href="{@docRoot}guide/topics/resources/runtime-changes.html" 43a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * >Handling Runtime Changes</a>. 44a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * 459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param newConfig The new device configuration. 469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project void onConfigurationChanged(Configuration newConfig); 48a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main 499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * This is called when the overall system is running low on memory, and 51a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * actively running processes should trim their memory usage. While 529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the exact point at which this will be called is not defined, generally 53a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * it will happen when all background process have been killed. 54a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * That is, before reaching the point of killing processes hosting 559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * service and foreground UI that we would like to avoid killing. 56a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * 57a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * <p>You should implement this method to release 58a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * any caches or other unnecessary resources you may be holding on to. 59a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * The system will perform a garbage collection for you after returning from this method. 60a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * <p>Preferably, you should implement {@link ComponentCallbacks2#onTrimMemory} from 61a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * {@link ComponentCallbacks2} to incrementally unload your resources based on various 62a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * levels of memory demands. That API is available for API level 14 and higher, so you should 63a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * only use this {@link #onLowMemory} method as a fallback for older versions, which can be 64a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * treated the same as {@link ComponentCallbacks2#onTrimMemory} with the {@link 65a23fd88729bd10c02a9d631c9954616b3a1d0f6fScott Main * ComponentCallbacks2#TRIM_MEMORY_COMPLETE} level.</p> 669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project void onLowMemory(); 689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 69