Search code examples
androidandroid-fragmentstalkbackaccessibility

How can a fragment announce itself on launch in Android Talkback?


I want Fragment to announce itself on launch in Android Talkback. Activity does announce itself when added 'android:label' on the activity tag in AndroidManifest file. How can I do that for Fragment?


Solution

  • You can use one of the Fragment lifecycle methods to announce it yourself.

    Fragments don't have an intrinsic title, and since they're basically Views + logic, it seems reasonable that the system can't predict when it would be appropriate to announce a newly added Fragment.

    Something like overriding onCreateView(View view, ...) and then calling view.announceForAccessibility("title of my fragment") would work.