---
title: Accessibility Delegates | Guardsquare
description: Learn how Accessibility Delegates are a vital feature for customizing app accessibility, which can be used to fine-tune defense against malicious activity.
---

[![guardsquare-logo](https://insights.guardsquare.com/hs-fs/hubfs/Logos/logo-white.png?length=536&name=logo-white.png "guardsquare-logo") ](https://23593082.hs-sites.com/)

- pricing

[Request Pricing](https://www.guardsquare.com/request-pricing?hsCtaTracking=646b0379-d596-4b1a-8526-2ccbdbb0f81b%7Ce8809087-a83f-4476-8b22-34b9572013fd)

[Login](https://customers.guardsquare.com/login?utm_referrer=https%3A%2F%2Fwww.guardsquare.com%2F)

En

- [中文](https://www.guardsquare.com/zh-hans)
- [한국어](https://www.guardsquare.com/ko)
- [Português](https://www.guardsquare.com/pt-br)
- [Español](https://www.guardsquare.com/es)

# [Mobile Application]

# Security Research Center

 Table of contents

# Accessibility delegates

|   | **Technique summary** |
| --- | --- |
| **Technique** | Accessibility delegates |
| **Against** | [Malicious accessibility services](https://23593082.hs-sites.com/knowledgebasetest/attacks/a11y-attacks#2) |
| **Limitations** | None |
| **Side effects** | Views that use protection based on accessibility delegates, will not be available for legitimate accessibility services as well, causing reduced functionality for the users relying on accessibility services. |
| **Recommendations** | Only use for views that users with accessibility needs do not need to work with. |

Accessibility Delegates in Android are a vital feature for customizing app accessibility. They allow developers to define or improve the accessibility of their views that may not be adequately served by the default [accessibility services](https://23593082.hs-sites.com/knowledgebasetest/attacks/a11y-attacks#2) provided by Android.

Accessibility Delegates can be used to fine-tune defense against malicious accessibility services. For example, malicious accessibility services can access text in Android Views.

![a11y-accessing-view-text](https://23593082.hs-sites.com/hs-fs/hubfs/knowledge-base-photos/a11y-accessing-view-text.gif?width=800&height=230&name=a11y-accessing-view-text.gif)

*Accessing view text with a11y services*

The defense solution constitutes registering delegates in sensitive views to modify the way accessibility events will originate from those views.

For example, to prevent accessibility services from accessing the view text, create a class inheriting from `View.AccessibilityDelegate`, and override the callbacks `onPopulateAccessibilityEvent` and `onInitializeAccessibilityNodeInfo`. In these callbacks, modify the text from the `AccessibilityEvent` object and from the `AccessibilityNodeInfo` object. This way, the accessibility events will be modified at their source, and no accessibility service will have access to the original text. Note that both callbacks need to be overridden, as each one of them protects against a different type of data recovery.

 public class MyA11yDelegate extends AccessibilityDelegate { // (...) @Override public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { super.onPopulateAccessibilityEvent(host, event); if (event.getText().size() > 0) { event.getText().clear(); event.getText().add("CENSORED"); } } @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); if (info.getText().toString().length() > 0) { info.setText("CENSORED"); } } }

Assign the delegate to sensitive views:

 MyA11yDelegate delegate = new MytA11yDelegate(); emailView.setAccessibilityDelegate(delegate); passwordView.setAccessibilityDelegate(delegate);

![a11y-delegates](https://23593082.hs-sites.com/hs-fs/hubfs/knowledge-base-photos/a11y-delegates.gif?width=800&height=300&name=a11y-delegates.gif)

*Failed view text access*

## [Guardsquare](https://23593082.hs-sites.com/knowledgebasetest/author/guardsquare)

Connect with the author

** Table of contents **

![HubSpot CMS](https://cdn2.hubspot.net/hubfs/302335/hubspot-cms-logo-gray.svg "HubSpot CMS")

[General Terms](https://23593082.hs-sites.com/terms-of-use) | [Privacy Policy](https://23593082.hs-sites.com/privacy-policy) | [Cookie Policy](https://23593082.hs-sites.com/cookie-policy)

Tervuursevest 362 bus 1, 3000 Leuven, Belgium | VAT: BE0550675829 |

© 2016-2026 Guardsquare nv. All rights reserved.

<https://www.facebook.com/guardsquare> <https://twitter.com/Guardsquare> <https://www.linkedin.com/company/guardsquare/> <https://www.youtube.com/channel/UCP9s5F1ksT1E-7vSF2CDyhw> <https://github.com/Guardsquare>

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Guardsquare",
    "url" : "https://23593082.hs-sites.com/knowledgebasetest/author/guardsquare"
  },
  "dateModified" : "2024-02-28T01:58:53.209Z",
  "datePublished" : "2024-02-13T18:26:15.000Z",
  "headline" : "Accessibility Delegates | Guardsquare",
  "mainEntityOfPage" : {
    "@id" : "https://23593082.hs-sites.com/knowledgebasetest/defense/a11y-delegates",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject"
    }
  }
}
```