1 /* 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 17 package android.content; 18 19 import android.annotation.NonNull; 20 import android.content.res.Configuration; 21 22 /** 23 * The set of callback APIs that are common to all application components 24 * ({@link android.app.Activity}, {@link android.app.Service}, 25 * {@link ContentProvider}, and {@link android.app.Application}). 26 * 27 * <p class="note"><strong>Note:</strong> You should also implement the {@link 28 * ComponentCallbacks2} interface, which provides the {@link 29 * ComponentCallbacks2#onTrimMemory} callback to help your app manage its memory usage more 30 * effectively.</p> 31 */ 32 public interface ComponentCallbacks { 33 /** 34 * Called by the system when the device configuration changes while your 35 * component is running. Note that, unlike activities, other components 36 * are never restarted when a configuration changes: they must always deal 37 * with the results of the change, such as by re-retrieving resources. 38 * 39 * <p>At the time that this function has been called, your Resources 40 * object will have been updated to return resource values matching the 41 * new configuration. 42 * 43 * <p>For more information, read <a href="{@docRoot}guide/topics/resources/runtime-changes.html" 44 * >Handling Runtime Changes</a>. 45 * 46 * @param newConfig The new device configuration. 47 */ onConfigurationChanged(@onNull Configuration newConfig)48 void onConfigurationChanged(@NonNull Configuration newConfig); 49 50 /** 51 * This is called when the overall system is running low on memory, and 52 * actively running processes should trim their memory usage. While 53 * the exact point at which this will be called is not defined, generally 54 * it will happen when all background process have been killed. 55 * That is, before reaching the point of killing processes hosting 56 * service and foreground UI that we would like to avoid killing. 57 * 58 * @deprecated Since API level 14 this is superseded by 59 * {@link ComponentCallbacks2#onTrimMemory}. 60 * Since API level 34 this is never called. 61 * Apps targeting API level 34 and above may provide an empty implementation. 62 */ 63 @Deprecated onLowMemory()64 void onLowMemory(); 65 } 66