Context.RegisterComponentCallbacks(IComponentCallbacks) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向上下文的基本应用程序添加新内容 ComponentCallbacks ,它将在调用 ActivityCallbacks 方法和其他组件的同一时间调用。
[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
参数
- callback
- IComponentCallbacks
要调用的接口。 这可以是接口 ComponentCallbacks 或 ComponentCallbacks2 接口。
- 属性
注解
向上下文的基本应用程序添加新内容 ComponentCallbacks ,它将在调用 ActivityCallbacks 方法和其他组件的同一时间调用。 请注意,em <>必须</em> 在将来适当时使用#unregisterComponentCallbacks;这不会为你删除。
之后 Build.VERSION_CODES#S,将 ComponentCallback 注册到通过 #createWindowContext(int, Bundle) 窗口上下文创建或 #createWindowContext(Display, int, Bundle) 将从窗口上下文接收的上下文,而不是从其基本应用程序接收 ComponentCallbacks#onConfigurationChanged(Configuration) 。 如果要在窗口上下文发生配置更改时处理与窗口上下文关联的 UI 组件,则非常有用。
之后 Build.VERSION_CODES#TIRAMISU,将 ComponentCallbacks 注册到 Activity 上下文将接收 ComponentCallbacks#onConfigurationChanged(Configuration) 其 Activity#onConfigurationChanged(Configuration) 基础应用程序而不是其基础应用程序。
之后 Build.VERSION_CODES#UPSIDE_DOWN_CAKE,将 ComponentCallbacks 注册到 android.inputmethodservice.InputMethodService 将从 InputmethodService 接收,而不是从其基本应用程序接收 ComponentCallbacks#onConfigurationChanged(Configuration) 。 如果要在 IME 发生配置更改时处理 UI 组件,这非常有用。
Java文档android.content.Context.registerComponentCallbacks(android.content.ComponentCallbacks)。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。