How to check if Talkback is active in JellyBean

后端 未结 4 1379
半阙折子戏
半阙折子戏 2021-01-06 08:49

This question asked how to know if Android Talkback is active; that worked until Jelly Bean. Starting from Android 4.1, that steps no longer work, because the mentioned curs

4条回答
  •  误落风尘
    2021-01-06 09:21

    You can check the enabled spoken accessibility servers

    fun Context.isScreenReaderEnabled(): Boolean {
        val accessibilityManager = getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
    
        if (!accessibilityManager.isEnabled)
            return false
    
        val serviceInfoList = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN)
    
        if (serviceInfoList.isNullOrEmpty())
            return false
    
        return true
    }
    

提交回复
热议问题