Taal

Context.RegisterComponentCallbacks(IComponentCallbacks) Method

Definition

Add a new ComponentCallbacks to the base application of the Context, which will be called at the same times as the ComponentCallbacks methods of activities and other components are called.

[Android.Runtime.Register("registerComponentCallbacks", "(Landroid/content/ComponentCallbacks;)V", "GetRegisterComponentCallbacks_Landroid_content_ComponentCallbacks_Handler")]
public virtual void RegisterComponentCallbacks(Android.Content.IComponentCallbacks? callback);
[<Android.Runtime.Register("registerComponentCallbacks", "(Landroid/content/ComponentCallbacks;)V", "GetRegisterComponentCallbacks_Landroid_content_ComponentCallbacks_Handler")>]
abstract member RegisterComponentCallbacks : Android.Content.IComponentCallbacks -> unit
override this.RegisterComponentCallbacks : Android.Content.IComponentCallbacks -> unit

Parameters

callback
IComponentCallbacks

The interface to call. This can be either a ComponentCallbacks or ComponentCallbacks2 interface.

Attributes

Remarks

Add a new ComponentCallbacks to the base application of the Context, which will be called at the same times as the ComponentCallbacks methods of activities and other components are called. Note that you must be sure to use UnregisterComponentCallbacks(IComponentCallbacks) when appropriate in the future; this will not be removed for you.

After S, registering the ComponentCallbacks to Context created via CreateWindowContext(Int32, Bundle) or CreateWindowContext(Display, Int32, Bundle) will receive OnConfigurationChanged(Configuration) from Window Context rather than its base application. It is helpful if you want to handle UI components that associated with the Window Context when the Window Context has configuration changes.

After Tiramisu, registering the ComponentCallbacks to Activity context will receive OnConfigurationChanged(Configuration) from OnConfigurationChanged(Configuration) rather than its base application.

After UpsideDownCake, registering the ComponentCallbacks to android.inputmethodservice.InputMethodService will receive OnConfigurationChanged(Configuration) from InputmethodService rather than its base application. It is helpful if you want to handle UI components when the IME has configuration changes.

Java documentation for android.content.Context.registerComponentCallbacks(android.content.ComponentCallbacks).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to