gpt4 book ai didi

android - 检测是否在 Android 辅助功能设置中启用了 'High contrast'

转载 作者:行者123 更新时间:2023-11-29 00:05:07 25 4
gpt4 key购买 nike

如何检测辅助功能设置中是否启用了“高对比度”设置(适用于 Android 5.0+)?

最佳答案

AccessibilityManager 类 ( see source here ) 中,您有一个名为 isHighTextContrastEnabled 的公共(public)方法,您可以使用它来获取信息:

/**
* Returns if the high text contrast in the system is enabled.
* <p>
* <strong>Note:</strong> You need to query this only if you application is
* doing its own rendering and does not rely on the platform rendering pipeline.
* </p>
*
* @return True if high text contrast is enabled, false otherwise.
*
* @hide
*/
public boolean isHighTextContrastEnabled() {
synchronized (mLock) {
IAccessibilityManager service = getServiceLocked();
if (service == null) {
return false;
}
return mIsHighTextContrastEnabled;
}
}

因此在您的代码中,您可以通过这样做来访问此方法(如果您在 Activity 中):

AccessibilityManager am = (AccessibilityManager) this.getSystemService(Context.ACCESSIBILITY_SERVICE);
boolean isHighTextContrastEnabled = am.isHighTextContrastEnabled();

关于android - 检测是否在 Android 辅助功能设置中启用了 'High contrast',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34411712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com