<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fernando García Lidón on Medium]]></title>
        <description><![CDATA[Stories by Fernando García Lidón on Medium]]></description>
        <link>https://medium.com/@cononube?source=rss-5cc6f3540946------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jE56ZPIiU0K3dRLqdRoTFQ.jpeg</url>
            <title>Stories by Fernando García Lidón on Medium</title>
            <link>https://medium.com/@cononube?source=rss-5cc6f3540946------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:32:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cononube/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing Android keyboard accessibility from your computer with scrcpy]]></title>
            <link>https://medium.com/@cononube/testing-android-keyboard-accessibility-from-your-computer-with-scrcpy-95d9a91ac9d8?source=rss-5cc6f3540946------2</link>
            <guid isPermaLink="false">https://medium.com/p/95d9a91ac9d8</guid>
            <category><![CDATA[scrcpy]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Fernando García Lidón]]></dc:creator>
            <pubDate>Wed, 21 Oct 2026 10:32:58 GMT</pubDate>
            <atom:updated>2026-10-21T10:32:58.205Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to make Android detect your macOS, Windows, or Linux keyboard as a physical device and test native keyboard shortcuts correctly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMrcKDJFoCskDqJnjmjf7w.jpeg" /><figcaption>An Android device mirrored on a computer while the computer keyboard controls Android shortcuts.</figcaption></figure><p>Typing inside a mirrored Android device is easy. Testing keyboard shortcuts correctly is not always so simple.</p><p>A mirroring tool may accept letters, Tab, or Enter while still capturing some shortcuts on the computer before they reach Android. In that case, the application appears to support keyboard input, but the test does not reproduce the behavior of a keyboard connected directly to the device.</p><p>In this post, we will use scrcpy to:</p><ul><li>Mirror an Android device.</li><li>Send the computer keyboard as a physical HID keyboard.</li><li>Open Android’s native Keyboard Shortcuts Helper.</li><li>Handle shortcuts correctly on non-US keyboard layouts.</li></ul><p>No Android application code is required.</p><h3>Before starting</h3><p>You will need:</p><ul><li>An Android target available through adb, usually a physical device.</li><li>A computer running macOS, Windows, or Linux.</li><li>USB debugging or Wireless debugging enabled.</li><li>scrcpy installed on your computer.</li></ul><p>An emulator can also appear as an adb target, although scrcpy is usually unnecessary because Android emulators already receive keyboard input directly from the computer.</p><p>The workflow in this article has been tested on macOS and Windows. scrcpy also officially supports Linux.</p><h3>Screen mirroring is not physical keyboard input</h3><p>Screen mirroring and physical keyboard forwarding are different things.</p><p>A mirroring tool can:</p><ul><li>Convert pressed keys into text.</li><li>Inject Android key events.</li><li>Capture shortcuts on the computer.</li><li>Simulate a physical HID keyboard.</li></ul><p>These methods may behave similarly inside a text field, but they are not equivalent when testing system or application shortcuts.</p><p>In my tests, Android Studio Device Mirroring and Vysor handled normal keyboard input, but some shortcuts remained captured on the computer and never reached the Android device.</p><p>This does not make scrcpy the only valid solution. I recommend it because its physical keyboard mode is explicit, free, open source, lightweight, and easy to start from a terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaS92eHOXYoLVBaeEQYseQ.jpeg" /><figcaption>Comparison between translated keyboard input and physical HID keyboard simulation on Android.</figcaption></figure><h3>Why scrcpy?</h3><p>scrcpy is a free and open-source tool for displaying and controlling Android devices from Linux, Windows, and macOS. It works through USB or TCP/IP and does not require root access or an application permanently installed on the Android device.</p><p>The relevant feature for this test is its UHID keyboard mode.</p><p>Instead of using the default Android API input mode, UHID makes Android detect the computer keyboard as a physical HID keyboard.</p><p>Download scrcpy only from its official GitHub repository, which the project identifies as its official distribution source.</p><h3>Let’s get started</h3><h4>Install scrcpy on macOS</h4><p>The simplest installation method on macOS is Homebrew:</p><pre>brew install scrcpy</pre><p>scrcpy also needs adb to connect to the Android device. If the adb command is not already available from your terminal, install Android Platform Tools:</p><pre>brew install --cask android-platform-tools</pre><p>Both commands are included in the official scrcpy installation instructions for macOS.</p><h4>Install scrcpy on Windows</h4><p>On Windows, you can install scrcpy from WinGet:</p><pre>winget install --exact Genymobile.scrcpy</pre><p>The WinGet installation also installs ADB and the required dependencies.</p><p>Alternatively, download the official Windows package, extract it and use the open_a_terminal_here.bat file included in the folder. This opens a terminal in the correct location so that you can run scrcpy commands directly.</p><h4>Install scrcpy on Linux</h4><p>Use the official static release or the package manager available in your Linux distribution. Installation commands vary between distributions, so check the official Linux instructions before installing it.</p><h3>Connect your Android device</h3><p>scrcpy communicates with Android through adb. You can connect the device through USB or wirelessly.</p><h4>USB connection</h4><p>Enable USB debugging under Android Developer options and connect the device to the computer.</p><p>Connect the device to your computer using USB and run:</p><pre>adb devices</pre><p>The first time you connect it, Android should display an authorization dialog. Unlock the device and accept the request.</p><p>After authorization, the terminal should show something similar to:</p><pre>List of devices attached<br>XXXXXXXXXXXX    device</pre><h4>Wireless connection</h4><p>On supported Android versions, enable:</p><pre>Developer options &gt; Wireless debugging</pre><p>The Android device and computer must be connected to the same network.</p><p>Select <strong>Pair device with pairing code</strong> and use the values shown on the Android screen:</p><pre>adb pair &lt;IP_ADDRESS&gt;:&lt;PAIRING_PORT&gt;</pre><p>If the device is not connected automatically after pairing, run:</p><pre>adb connect &lt;IP_ADDRESS&gt;:&lt;DEBUGGING_PORT&gt;</pre><p>Finally, verify the connection:</p><pre>adb devices</pre><p>Android supports wireless adb pairing from Android 11, and scrcpy can use an existing TCP/IP connection in the same way as a USB connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vOwHKO3T4KYefhO_pGiPg.jpeg" /><figcaption>USB and wireless methods for connecting an Android device to adb.</figcaption></figure><h3>Start scrcpy in physical keyboard mode</h3><p>This is the most important command in the article:</p><pre>scrcpy --keyboard=uhid</pre><p>Its shorter equivalent is:</p><pre>scrcpy -K</pre><p>The -K option makes Android detect the computer keyboard as a physical HID keyboard. It also works when the device is connected wirelessly.</p><p>Do not forget -K.</p><p>Running this command:</p><pre>scrcpy</pre><p>uses scrcpy’s default SDK input mode. That mode can still type text and send key events, but it does not simulate a physical keyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JETogTA47ho0fUOt2DRGzA.jpeg" /><figcaption>A terminal starting scrcpy with the physical keyboard option enabled.</figcaption></figure><h3>Check the physical keyboard settings</h3><p>Once scrcpy starts in UHID mode, Android may show a physical keyboard section under its language and input settings.</p><p>The available options depend on the Android version and device manufacturer.</p><p>Some devices let you select a keyboard layout. Others only show options such as:</p><ul><li>Keep the on-screen keyboard visible.</li><li>View Android’s native keyboard shortcuts.</li></ul><p>If Android offers a layout selector, choose the layout that matches your computer keyboard.</p><p>If no selector appears, continue with the test. The next step will confirm which physical keys Android is actually receiving.</p><p>Avoid depending on one exact settings path. The screen and its available options are not consistent across all Android versions.</p><h3>Open Android’s native Keyboard Shortcuts Helper</h3><p>Android provides a native screen that displays available system and application shortcuts.</p><p>Keep the scrcpy window active and press:</p><pre>Meta + /</pre><p>The Meta key depends on the computer:</p><ul><li>macOS: Command</li><li>Windows: Windows key</li><li>Linux: Meta or Super</li></ul><p>Android officially documents Command as Meta on macOS and the Windows key as Meta on Windows. The Keyboard Shortcuts Helper is available from Android 7.0.</p><p>If the helper opens, Android is receiving the combination from your computer keyboard.</p><p>Try some of the shortcuts displayed inside the helper. This is a more useful validation than checking only whether you can type text or navigate with Tab, because those basic interactions can also work through regular mirroring modes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4sYyQF6ORGUvfaIHN17rQ.jpeg" /><figcaption>Android’s native Keyboard Shortcuts Helper opened from a US QWERTY computer keyboard through scrcpy.</figcaption></figure><h4>Using a non-US keyboard?</h4><p>Users with a standard US QWERTY keyboard can press the documented / key, located immediately to the left of the right Shift key.</p><p>On other keyboard layouts, that physical key may display a different symbol.</p><p>This matters because the shortcut refers to the Android slash key event, not necessarily to the combination that produces the / character in your language.</p><p>For example, on a Spanish Apple keyboard:</p><ul><li>/ is typed with Shift + 7.</li><li>The key in the US slash position displays - and _.</li><li>The helper opens by pressing Command together with that physical -/_ key.</li></ul><p>Therefore, on a non-US keyboard, do not search only for the combination that types /.</p><p>Use this physical reference:</p><blockquote><strong><em>Press Meta together with the key located immediately to the left of the right Shift key on a US QWERTY keyboard.</em></strong></blockquote><p>The same issue can appear with Spanish, Italian, German, French, and other keyboard layouts where the printed symbols differ from US QWERTY.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QN0KFz60jXHYmMKwbmyOg.jpeg" /><figcaption><em>US and non-US keyboards showing different symbols in the physical slash-key position.</em></figcaption></figure><p>If the helper still does not open, check the command first:</p><pre>scrcpy -K</pre><p>Forgetting -K is one of the easiest ways to think the shortcut or keyboard mapping is not working.</p><h3>Common problems</h3><h4>The device does not appear in adb devices</h4><p>For USB, unlock the device and accept the debugging authorization dialog.</p><p>For Wi-Fi, confirm that both devices are on the same network and that Wireless debugging is still enabled.</p><h4>Text input works, but the shortcuts helper does not open</h4><p>Check these three points:</p><ol><li>scrcpy was started with -K.</li><li>The scrcpy window is active.</li><li>You are pressing the physical US slash-position key, not only the combination that types /.</li></ol><h4>Android shows no keyboard layout selector</h4><p>This depends on the Android version and manufacturer. Some devices expose only the on-screen keyboard option and the native shortcuts list.</p><p>Continue with the real validation: open the Keyboard Shortcuts Helper and test the shortcuts shown there.</p><h4>A shortcut is still captured by the computer</h4><p>The operating system or another desktop application may already use the same combination. Close the conflicting application or disable its shortcut before repeating the test.</p><h3>It’s a wrap</h3><p>Screen mirroring does not always mean that Android receives your computer keyboard as a physical keyboard.</p><p>scrcpy is not the only possible solution, but its UHID mode provides a simple and reproducible setup:</p><pre>scrcpy -K</pre><p>From there, the key checks are straightforward:</p><ul><li>Confirm that Android is connected through adb.</li><li>Start scrcpy with UHID keyboard mode.</li><li>Open the native Keyboard Shortcuts Helper with Meta + /.</li><li>On non-US keyboards, use the physical US slash-key position.</li><li>Test the shortcuts displayed by Android.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95d9a91ac9d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improve your Android accessibility with toggleables]]></title>
            <link>https://medium.com/@cononube/improve-your-android-accessibility-with-toggleables-b6f7239f35e1?source=rss-5cc6f3540946------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6f7239f35e1</guid>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[talkback]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[feature-toggles]]></category>
            <dc:creator><![CDATA[Fernando García Lidón]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 21:27:04 GMT</pubDate>
            <atom:updated>2026-07-28T21:27:04.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*oLahEq5KbzdTAAfviXQb4A.png" /><figcaption>Photo by <a href="https://unsplash.com/@epicantus?utm_source=medium&amp;utm_medium=referral">Daria Nepriakhina</a></figcaption></figure><p>Customizing the views in our Apps is something very common in our daily development of screens but we often forget to review the accessibility part, so we end up creating beautiful visual components but not very accessible for people with disabilities.</p><p>In this post we are going to see how we can improve accessibility in a personalized way for our Android apps working with <a href="https://developer.android.com/develop/ui/views/components/togglebutton">toggleables Views</a>, so that you can understand and apply any accessibility customization according to the needs of your App.</p><h3>Before starting</h3><p>The accessibility tests in this article use the most common accessibility service on Android: <a href="https://www.youtube.com/watch?v=MEp9DtiTw3s"><strong>Talkback</strong></a>. Nevertheless, the code implemented here is standard for any other accessibility service that requires it.</p><h3>Let’s get started</h3><p>Let’s say we have an application that displays a Switch-type configuration but with an advanced layout where it has a title, a subtitle, and an image associated with it.</p><figure><img alt="Example of a custom Switch component with a left image, title and subtitle." src="https://cdn-images-1.medium.com/max/1024/1*7LivkLG65piJxuCALQrHHA.jpeg" /><figcaption>Example of a custom Switch component with a left image, title and subtitle.</figcaption></figure><p>Following is the code of this custom component. Note that inside the ConstraintLayout you can add as many customizations as you want to your toggleable component.</p><pre>&lt;androidx.constraintlayout.widget.ConstraintLayout<br>    android:id=&quot;@+id/custom_toggleable_root_layout&quot;<br>    ... &gt;<br><br>    &lt;ImageView<br>        android:id=&quot;@+id/custom_toggleable_left_image&quot;<br>        ... /&gt;<br><br>    &lt;TextView<br>        android:id=&quot;@+id/custom_toggleable_title&quot;<br>        ... /&gt;<br><br>    &lt;TextView<br>        android:id=&quot;@+id/custom_toggleable_subtitle&quot;<br>        ... /&gt;<br><br>    &lt;androidx.appcompat.widget.SwitchCompat<br>        android:id=&quot;@+id/custom_toggleable_switch&quot;<br>        ... /&gt;<br><br>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</pre><p>From here, let’s continue with this simple example to focus on what’s important: <strong>how accessible is this component?</strong> H<strong>ow can accessibility be improved?</strong></p><p>Here’s a video of Talkback’s default behavior with the component:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FWmW3pFXcy08%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWmW3pFXcy08&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWmW3pFXcy08%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbbcef7cac3dd5fc38d256dc429ce75f/href">https://medium.com/media/bbbcef7cac3dd5fc38d256dc429ce75f/href</a></iframe><p>As seen in the video, Talkback’s focus moves independently between the component’s elements. However, if we look at other apps that follow the <a href="https://www.w3.org/TR/WCAG22/">WCAG</a> accessibility standard, such as the Android Settings app, we see the following:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8Jxsr0KoJiM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8Jxsr0KoJiM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8Jxsr0KoJiM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f0dae01ffe780a189f8588cc945af01/href">https://medium.com/media/1f0dae01ffe780a189f8588cc945af01/href</a></iframe><p>In this case, the focus is managed as a group for the entire component. This offers us two main advantages:</p><ol><li>More efficient communication with the user by announcing all the elements at once.</li><li>Easy Switch turn-on and turn-off with a single group focus.</li></ol><h3>Hands on</h3><p>Now that we have seen how the accessibility can be improved for custom toggleables, let’s understand the steps to achieve it.</p><p>We are going to see how to configure the accessibility of the initial component to offer the best experience to our users.</p><h4>Disable the current accessibility configuration</h4><p>First, disable the accessibility configuration of our child views by setting <em>importantForAccessibility=”no”</em>. It will be managed as a group in the root ConstraintLayout.</p><pre>&lt;ImageView<br>        android:id=&quot;@+id/custom_toggleable_image&quot;<br>        android:importantForAccessibility=&quot;no&quot;<br>        ... /&gt;<br><br>&lt;TextView<br>        android:id=&quot;@+id/custom_toggleable_title&quot;<br>        android:importantForAccessibility=&quot;no&quot;<br>        ... /&gt;<br><br>&lt;TextView<br>        android:id=&quot;@+id/custom_toggleable_subtitle&quot;<br>        android:importantForAccessibility=&quot;no&quot;<br>        ... /&gt;<br><br>&lt;androidx.appcompat.widget.SwitchCompat<br>        android:id=&quot;@+id/custom_toggleable_switch&quot;<br>        android:clickable=&quot;false&quot;<br>        android:importantForAccessibility=&quot;no&quot;<br>        ... /&gt;</pre><p>Note that clicking is also disabled for Switch, as we do not want Talkback to focus on the Switch at all. We will see later why this is necessary.</p><h4>Customize the root layout accessibility</h4><p>Since we are going to apply a custom accessibility configuration, we need to create a custom Switch component class.</p><pre>class CustomSwitchComponent @JvmOverloads constructor(<br>    context: Context,<br>    attrs: AttributeSet? = null,<br>    defStyle: Int = 0<br>) : ConstraintLayout(context, attrs, defStyle) {<br>    // Custom accessibility configuration will go here<br>}</pre><p>Now we can change the generic ConstraintLayout in the XML file to the custom one we just created.</p><pre>&lt;com.your.package.CustomSwitchComponent<br>        android:id=&quot;@+id/custom_toggleable_root_layout&quot;<br>        ... &gt;<br><br>        &lt;!-- Child views --&gt;<br><br>&lt;/com.your.package.CustomSwitchComponent&gt;</pre><h4>Add a content description</h4><p>After creating the custom component, the first thing we are going to do is create a content description since the accessibility of the child views have been disabled with <em>importantForAccessibility=”no”.</em></p><pre>class CustomSwitchComponent(...) {<br><br>    private lateinit var titleView: TextView<br>    private lateinit var subtitleView: TextView<br>    private lateinit var switchView: SwitchCompat<br><br>    override fun onFinishInflate() {<br>        super.onFinishInflate()<br><br>        titleView = findViewById(R.id.custom_toggleable_title)<br>        subtitleView = findViewById(R.id.custom_toggleable_subtitle)<br>        switchView = findViewById(R.id.custom_toggleable_switch)<br><br>        initAccessibilityConfiguration()<br>    }<br>    <br>    private fun initAccessibilityConfiguration() {<br>        contentDescription = &quot;${titleView.text}. ${subtitleView.text}&quot;<br>    }<br>}</pre><h4>Identify the component as a Switch</h4><p>The next step is to identify our custom component as a Switch so that it is correctly announced by Talkback.</p><p>To do this, we need to change the <em>className</em> attribute in the AccessibilityEvent and AccessibilityNodeInfo classes when they are initialized.</p><pre>class CustomSwitchComponent(...) {<br><br>    ...<br><br>    override fun onInitializeAccessibilityEvent(event: AccessibilityEvent?) {<br>        super.onInitializeAccessibilityEvent(event)<br>        event?.className = android.widget.Switch::class.java.name<br>    }<br><br>    override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo?) {<br>        super.onInitializeAccessibilityNodeInfo(info)<br>        info?.className = android.widget.Switch::class.java.name<br>    }<br>}</pre><h4>Provide the Switch state to the component</h4><p>To provide the state of the Switch to our component, there is the <em>setStateDescription</em> function that we can use in the following way:</p><pre>private fun initAccessibilityConfiguration() {<br>    ...<br>    ViewCompat.setStateDescription(this@CustomSwitchComponent, ViewCompat.getStateDescription(switchView))<br>}</pre><p>The previous code is fine, and we can check that Talkback does indeed announce the state of the Switch in our component.</p><p>But this does not end here… The state will not be automatically updated in our component when we change the Switch state! We need the component to manage the update of the Switch state in a controlled manner.</p><p>This is the reason for disabling the click on the Switch previously, as we want all state changes on the Switch to go through our component so we can update the state properly.</p><p>A simple way to achieve this is by creating public utility functions so that the state of the Switch can be changed at the same time as we update it in our component.</p><pre>fun changeSwitchState(enable: Boolean) {<br>    switchView.isChecked = enable<br>    ViewCompat.setStateDescription(this@CustomSwitchComponent, ViewCompat.getStateDescription(switchView))<br>}<br><br>fun getSwitchState() = switchView.isChecked</pre><p>With these methods, we can change the state of the Switch through our custom component.</p><pre>val component: CustomSwitchComponent = findViewById(R.id.custom_toggleable_root_layout)<br>component.setOnClickListener {<br>    component.changeSwitchState(!component.getSwitchState())<br>}</pre><p>You now have a custom toggleable component with great accessibility configuration. It looks pretty good, huh?</p><p>But that’s not enough… we’re going to further improve accessibility in our custom Switch component.</p><h4>Improve the component click announcement</h4><p>If we test the component with Talkback we can see that it announces “Double-tap to <strong>activate</strong>”.</p><p>This is not entirely wrong, but if we test Talkback with an isolated Switch, we will see that it announces “Double-tap to <strong>toggle</strong>”, which gives more context to the user than just “activate”.</p><p>Since Android does not support getting this value, there is no way to get the <em>ACTION_CLICK</em> value from the Switch component directly unlike with the <em>stateDescription </em>value.</p><p>So, to change this part of the announcement we do it in the following way:</p><pre>override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo?) {<br>    ...<br>    info?.addAction(<br>        AccessibilityNodeInfo.AccessibilityAction(<br>            AccessibilityNodeInfoCompat.ACTION_CLICK,<br>            &quot;toggle&quot; // Remember to use a stringRes reference instead of hardcoded text.<br>        )<br>    )<br>}</pre><p>With this code we can even further specify the click announcement depending on the state of the switch.</p><pre>info?.addAction(<br>    AccessibilityNodeInfo.AccessibilityAction(<br>        AccessibilityNodeInfoCompat.ACTION_CLICK,<br>        if (switchView.isChecked) &quot;turn off&quot; else &quot;turn on&quot;<br>    )<br>)</pre><p>So now, Talkback will announce one or another text depending on the state of the switch:</p><ul><li>Switch is ON → “Double-tap to turn off”</li><li>Switch is OFF → “Double-tap to turn on”</li></ul><h3>It’s a wrap</h3><p>Congratulations! You have created a custom Switch component with excellent accessibility configuration that will make your App more accessible to users.</p><p>Let’s see how our component looks like with all these accessibility improvements.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7LM7zroAw-E%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7LM7zroAw-E&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7LM7zroAw-E%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c56b57405ec8963c90536fe74926b51/href">https://medium.com/media/5c56b57405ec8963c90536fe74926b51/href</a></iframe><p>You can check the complete code of this blog in our open source repository: <a href="https://github.com/Telefonica/accessibility-catalog/tree/main/app/src/main/java/com/telefonica/apps/accessibility_catalog/view/screens/implementations/views/toggleables">Accessibility Catalog</a>.</p><p>In addition, this component has been added to <a href="https://github.com/Telefonica/mistica-android">Mistica Android</a>, the open source component library that we have at Telefonica. You can get more information about the implementation in Mistica in the <a href="https://github.com/Telefonica/mistica-android/tree/main/library/src/main/java/com/telefonica/mistica/list#toggleables">Lists section</a>.</p><p>Any suggestions or improvements are welcome. Your valuable contributions helps create more accessible Apps for people around the world.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6f7239f35e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>