ASingal
ASingal

Reputation: 121

Android - Preventing TalkBack to read the application Name and current Orientation

Problem is I am using TTS to read a long string message when my activity is launched, but TalkBack automatically reads the application name in the middle of it and cuts the long string and is very annoying.

I would like to disable the TalkBack read the Application name every time an activity is launched. Removing its android:label attribute is not a viable solution as the application is controlled by someone else and I have no control over it.

So, Is there any API that I could call to prevent the TalkBack feature from reading the application name when an application is launched?

Any Help would be highly appreciated.

Thanks a lot in advance.

Regards, Ashok

Upvotes: 10

Views: 9855

Answers (6)

verunar
verunar

Reputation: 874

In my case the app name was mispronounced by TalkBack. I fixed that by correcting the string name in strings.xml file.

<resources>
  <string name="app_name">Your App Name</string>
</resources>

What I previously had there was a name without spaces.

<resources>
  <string name="app_name">YourAppName</string>
</resources>

I hope that if you just left it empty or with empty space, you would get your desired effect.

Upvotes: 0

Shilbodhi Shambharkar
Shilbodhi Shambharkar

Reputation: 71

You should add this to AndroidManifest.xml

<activity
            android:name="com.mobile.myapp.test"
            android:label="About"
            android:screenOrientation="portrait" />

Leave android:label empty if you don't want TalkBack to read activity name.

Upvotes: 7

Pavlos
Pavlos

Reputation: 934

For Preventing TalkBack to read the application Name every time you switch activity is to set a name (label) of the Activity in Manifest:

<activity
        android:name=".pavlos.myActivity"
        android:label="Pavlos Activity" />

Adding android:name="" to Manifest will stop TalkBack announcing the name of the App every time you switch Activities.

Upvotes: 0

Eng-Ahmed Elsayed
Eng-Ahmed Elsayed

Reputation: 31

But this line in onCreate of Launcher Activity

Kotlin:

ViewCompat.setImportantForAccessibility(window.decorView,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO)

Java:

ViewCompat.setImportantForAccessibility(getWindow().getDecorView(),
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);

This worked for me.

Upvotes: 3

Satishkumar
Satishkumar

Reputation: 95

A solution would be to override dispatchPopulateAccessibilityEvent() in Activity to return true. This will prevent Talkback from announcing activity label.

Upvotes: 9

CommonsWare
CommonsWare

Reputation: 1007574

So, Is there any API that I could call to prevent the TalkBack feature from reading the application name when an application is launched?

Not that I am aware of.

Problem is I am using TTS to read a long string message when my activity is launched, but TalkBack automatically reads the application name in the middle of it and cuts the long string and is very annoying.

Then delay your "long string message" a bit, to give time for TalkBack to do its standard announcements.

Upvotes: 2

Related Questions