Saeed ur Rahman
Saeed ur Rahman

Reputation: 11

How to Programmatically on/off talkback from main activity

I would like to programmatically enable/disable "setting>Accessibility>talkback" Services. There is a part in my application where I want talkback service 'ON' and in the other part of my app, I want normal behaviour(i.e without talkback). I could not found any solution of this problem. Please help!

Upvotes: 1

Views: 2477

Answers (1)

AADProgramming
AADProgramming

Reputation: 6345

Not sure why you want to toggle ON/OFF for the whole talkback service.

An alternate approach could be to turn off accessibility (talkback) for an individual Android widget component such as TextView in your application.

To achieve this, simply add In your XML file, set the importance to "no" for a specific TextView.

<TextView
    android:importantForAccessibility="no"
    ... />

Or you want runtime control, use below from your JAVA code:

view.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);

This way, your application has finer control over Accessibility while honoring the user's Accessibility Settings.

NOTE: Above API/XML Attribute was introduced in Android Since API 16, And with revision 22 it's now in the v4 support library. http://developer.android.com/tools/support-library/index.html

Upvotes: 6

Related Questions