I would like to announce the loading text on an android intermediate progressbar. I want to output something like this for disabled people who are using talkback service on the Android device when an intermediate progressbar is loading.
- File is loading.
- File is fetching.
- File is converting.
- File is loaded.
I checked around google and found that I could use:
1) announceForAccessibility on progressbar view. (Not working in my case, only works when I load it with a Handler)
My code
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onResume() {
super.onResume()
val progressbar: ProgressBar = findViewById(R.id.testProgressBar)
// progressbar.announceForAccessibility("My name is Neo "); // not working
Handler().postDelayed(object : Runnable {
override fun run() {
progressbar.announceForAccessibility("My name is Neo ");
}
}, 1000)
}
Do you guys have any other suggestion to solve this kind of problem? I wonder how people got working at so many places https://www.programcreek.com/java-api-examples/?class=android.view.View&method=announceForAccessibility
Thanks for your help.
Make your progressbar focusable and then send custom content description based on your requirement. Talkback will handle that for you.