'Android Accessibility onInitializeAccessibilityNodeInfo not called

I created a custom tab view and I am attempting to set up the correct accessibility for this custom view. Within the Fragment's onViewCreated, I am setting the desired roleDescription:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    binding.customViewFoo.also { customViewFoo ->
        ViewCompat.setAccessibilityDelegate(customViewFoo,
            object : AccessibilityDelegateCompat() {
                override fun onInitializeAccessibilityNodeInfo(v: View, info: AccessibilityNodeInfoCompat) {
                    super.onInitializeAccessibilityNodeInfo(v, info)
                    info.roleDescription = "Custom View Foo"
                }
            })
    }
}

However, the function onInitializeAccessibilityNodeInfo is not being called. Looking at Android Accessibility — Resolving common Talkback issues in the Roles section, I don't see a difference between my code and her example other than her example is set within an Activity. I also looked at the Make Custom Views More Accessible on the Android site and it says pretty much the same thing.

Thoughts on what I am missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source