how to detect accessibility settings on android is enabled/disabled

前端 未结 5 1313
清歌不尽
清歌不尽 2021-01-28 12:34

I\'m particularly interested in high contrast text, color correction, and magnification settings. I did some research online, couldn\'t fi

5条回答
  •  北海茫月
    2021-01-28 12:59

    Maybe can be considered sloppy, using androidx.core:core-ktx's getSystemService extension,

    isHighTextContrastEnabled = try {
        context.getSystemService()?.run {
            (javaClass.getMethod("isHighTextContrastEnabled").invoke(this) as? Boolean)
        } ?: false
    } catch (e: Exception) {
        e.printStackTrace()
        false
    }
    

提交回复
热议问题