People who rely on an accessibility service to use mobile devices benefit from clearly displayed links. For example, someone who is blind and uses the TalkBack screen reader can easily access links from the local context menu.
Android offers developers several different ways to display text that is styled and behaves as a hyperlink. Some approaches support accessibility services more reliably than others.
If you use
URLSpan, use an absolute URL (
https://android.com/robots.txt), not a relative URL (
In Android versions prior to 8.0 (API level 26), it may be difficult for some accessibility services to detect and activate
ClickableSpan reliably. For apps that are available on these SDK versions, consider using a URLSpan with a matching
IntentFilter to handle the click action, as an accessibility service may activate these hyperlinks via an intent broadcast.
When using TalkBack to speak text containing a hyperlink, a well implemented user interface produces an auditory icon as the hyperlinked text is spoken, and the linked text appears in the "Links" sub-menu of TalkBack's local context menu.
To manually verify if an app is displaying hyperlinked text to accessibility services:
- Turn on TalkBack.
- Open the app.
- Move accessibility focus to the item containing the hyperlink.
- As the hyperlinked area of text within that item is spoken, listen for a chime to indicate hyperlinked text.
- While the item containing hyperlinked text has accessibility focus, open TalkBack's local context menu.
- Check if the hyperlinked text appears in the "Links" sub-menu.
Android's automated testing tools can detect incorrectly implemented hyperlinks. Consider using Accessibility Scanner for Android for manual testing of your app on-device. For automated tests, turn on accessibility checking in Espresso and Robolectric.