本文介绍了获取启用/禁用状态和可访问性颜色反转模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,当用户启用辅助功能颜色反转模式时,我需要对 UI 进行一些更改.

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

我们是否有任何 api 来检查 android 中颜色反转模式的启用/禁用状态?

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

推荐答案

以下是检查无障碍反转模式启用/禁用状态的代码.在某些手机反转模式下将显示为负色".

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;

}

这篇关于获取启用/禁用状态和可访问性颜色反转模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 19:13