Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

android - Get enable/disable status and of accessibility Colour inversion mode

In my application i need to make some UI changes when user enable accessibility colour inversion mode.

Do we have any api to check enable/disable status of colour inversion mode in android?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Below is the code to check enable/disable status of accessibility inversion mode. In some phone inversion mode will be available as "Negative colour".

public boolean isInversionModeEnabled() {
    boolean isInversionEnabled =  false;
    int accessibilityEnabled = 0;
    try {
        accessibilityEnabled = Settings.Secure.getInt(this.getContentResolver(),
                android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
    } catch (SettingNotFoundException e) {
        Log.d(TAG, "Error finding setting ACCESSIBILITY_DISPLAY_INVERSION_ENABLED: " + e.getMessage());
        Log.d(TAG, "Checking negative color enabled status");
        final String SEM_HIGH_CONTRAST = "high_contrast";
        accessibilityEnabled = Settings.System.getInt(getContentResolver(), SEM_HIGH_CONTRAST, 0);
    }
    if (accessibilityEnabled == 1) {
        Log.d(TAG, "inversion  or negative colour is enabled");
        isInversionEnabled = true;
    } else {
        Log.d(TAG, "inversion  or negative colour is disabled");
    }
    return isInversionEnabled;

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...