检测是否在 Android 辅助功能设置中启用了“高对比度" [英] Detect if 'High contrast' is enabled in Android accessibility settings
本文介绍了检测是否在 Android 辅助功能设置中启用了“高对比度"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检测是否在辅助功能设置中启用了高对比度"设置(适用于 Android 5.0+)?
How can I detect if 'High Contrast' setting (available on Android 5.0+) is enabled in Accessibility settings?
推荐答案
在 AccessibilityManager
类 (在此处查看源代码)您有一个名为 isHighTextContrastEnabled
的公共方法,您可以使用它获取您的信息:
In the AccessibilityManager
class (see source here) you have a public method called isHighTextContrastEnabled
that you can use to get your information:
/**
* 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
中):
So in your code, you can access this method by doing so (if you're in an Activity
):
AccessibilityManager am = (AccessibilityManager) this.getSystemService(Context.ACCESSIBILITY_SERVICE);
boolean isHighTextContrastEnabled = am.isHighTextContrastEnabled();
这篇关于检测是否在 Android 辅助功能设置中启用了“高对比度"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文