开发者控制台
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Implement Reading and Subscribing to AD/CC (Fire Tablets)

As a developer of third party apps, you might want to be able to read and subscribe to the audio description (AD) and closed caption (CC) settings so that you can tell if users have enabled them on their device. This page discusses how your Fire tablet app can read and subscribe to these settings.

Audio description

Audio description is a secure setting that you can add in through Fire OS.

Implement audio description

The key for this setting is defined as accessibility_audio_descriptions_enabled. The value is only added to secure settings when the user toggles it on for the first time. The default value is 0 (off), but after being set up and toggled on, the value changes to 1 (on).

Read the AD setting

Since this is a regular secure setting, you can read it through Settings.Secure.getInt(ContentResolver cr, String name, int def). For more details, see the getInt function.

Here is a code example for reading the AD setting:

// Grab the String for the Audio Description Secure Setting
static final String AUDIO_DESCRIPTION = "accessibility_audio_descriptions_enabled";

// The default value should always be off (0).
int audioDescEnabled = Settings.Secure.getInt(getApplicationContext().getContentResolver(),
AUDIO_DESCRIPTION, 0);

// Get a boolean value for whether Audio Description is Enabled.
boolean enabled = (audioDescEnabled == 1);

Log.d(TAG, "Audio Description Enabled is " + enabled);

Subscribe to the AD setting

You can subscribe to the AD setting by creating and registering a ContentObserver for it. For more details, see the ContentObserver API reference.

Here is a code example for subscribing to changes in the AD setting:

ContentResolver contentResolver = getApplicationContext().getContentResolver();

// Grab the String for the Audio Description Secure Setting
static final String AUDIO_DESCRIPTION = "accessibility_audio_descriptions_enabled";

// Grab the URI for the Audio Description Secure Setting
static final Uri audio_uri = Settings.Secure.getUriFor
("accessibility_audio_descriptions_enabled");

// Set up a Content Observer
ContentObserver observer = new ContentObserver(new Handler()) {
     @Override
     public void onChange(boolean selfChange, Uri uri) {
         // Check if the changed URI matches the Audio Description URI
        if (uri != null && uri.equals(audio_uri)) {
            int enabled = Settings.Secure.getInt(getApplicationContext().getContentResolver(),
AUDIO_DESCRIPTION, 0);
            Log.d(TAG, "Audio Description enabled? " + enabled);
        }
    }
};

// Register for changes to the Audio Description Secure Setting
contentResolver.registerContentObserver(audio_uri, false, observer);

Closed caption

Closed caption is also stored by a secure setting from the Android Open Source Project (AOSP).

Implement closed caption

Use CaptioningManager to read and subscribe to the enablement setting of whether CC is enabled or not. To retrieve a CaptioningManager, use get SystemService(Context.CAPTIONING_SERVICE). For more details, see the CaptioningManager class and the CAPTIONING_SERVICE Context constant.

Read the CC setting

To read the CC setting, use CaptioningManager to call isEnabled(). The default value is false (off).

Here is a code example for reading (and logging) the CC setting:

// Import CaptioningManager from Android
import android.view.accessibility.CaptioningManager;

// Retrieve a Captioning Manager from the Context
CaptioningManager captioningManager = (CaptioningManager) getApplicationContext().getSystemService
(Context.CAPTIONING_SERVICE);

// Read and Log what the Closed Caption Setting is.
Log.d(TAG, "Closed Caption Enabled is " + captioningManager.isEnabled());

Subscribe to the CC setting

To subscribe to the CC setting, set up and add a CaptioningChangeListener to the CaptioningManager. For more details, see the addCaptioningChangeListener function.

The public method, onEnabledChanged(boolean enabled) is called when the CC setting is changed.

Here is a code example for subscribing to changes in the CC setting:

// Import CaptioningManager from Android
import android.view.accessibility.CaptioningManager;

// Retrieve a Captioning Manager from the Context
CaptioningManager captioningManager = (CaptioningManager) getApplicationContext().getSystemService
(Context.CAPTIONING_SERVICE);

// Setup a CaptioningChangeListener.
CaptioningManager.CaptioningChangeListener captionListener = new CaptioningManager.
CaptioningChangeListener() {
    // In this case, we print a log statement when the closed caption is enabled or disabled.
    @Override
    public void onEnabledChanged(boolean enabled) {
        Log.d(TAG, "Captions are enabled? " + enabled);
    }
};

// Add the listener for changes in CaptioningManager
captioningManager.addCaptioningChangeListener(captionListener);

Last updated: Aug 22, 2025