Share via


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 <em>must</em> be sure to use #unregisterComponentCallbacks when appropriate in the future; this will not be removed for you.

After Build.VERSION_CODES#S, Registering the ComponentCallbacks to Context created via #createWindowContext(int, Bundle) or #createWindowContext(Display, int, Bundle) will receive ComponentCallbacks#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.

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