How to extract the text from Views in AccessibilityDelegate's AccessibilityNodeInfo?
<p>I am trying to get TalkBack to say what is in the text that is inside the <code>host</code> View, along with " is cool" afterwards. </p>

<p>To do this, I am setting an accessibility delegate on a linear layout, but the <code>info</code> parameter's text and contentDescription properties are always null. i.e. <code>info.getText()</code> and <code>info.getContentDescription()</code> are always returning null. I cannot seem to extract the text from the nested TextViews.</p>

<p>The <code>host</code> parameter is thus a linear layout, which contains another nested linear layout inside of it. This nested linear layout in turn contains more nested layouts and text views as their children. (I am targeting API 21+)</p>

<pre><code>linearLayout.setAccessibilityDelegate(new View.AccessibilityDelegate()
{
    @Override
    public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info)
    {
        super.onInitializeAccessibilityNodeInfo(host, info);

        String newWordsToSay = info.getText() + " is cool"
        //info.getText() CRASHES due to null pointer exception
        info.setContentDescription(info.setText(newWordsToSay));
    }
});
</code></pre>

<p>EDIT: On checking the <code>host</code> param, all of the expected nested TextViews are there, with their respective text fields. The problem is, I cannot seem to extract the text from them.</p>

<p>Any help would be appreciated.</p>