diff --git a/packages/core/accessibility/accessibility-service.android.ts b/packages/core/accessibility/accessibility-service.android.ts index 91ce754ae..898838670 100644 --- a/packages/core/accessibility/accessibility-service.android.ts +++ b/packages/core/accessibility/accessibility-service.android.ts @@ -71,19 +71,20 @@ function ensureStateListener(): SharedA11YObservable { } }, }); - - touchExplorationStateChangeListener = new android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener({ - onTouchExplorationStateChanged(enabled) { - updateAccessibilityState(); - - if (Trace.isEnabled()) { - Trace.write(`TouchExplorationStateChangeListener state changed to: ${!!enabled}`, Trace.categories.Accessibility); - } - }, - }); - accessibilityManager.addAccessibilityStateChangeListener(accessibilityStateChangeListener); - accessibilityManager.addTouchExplorationStateChangeListener(touchExplorationStateChangeListener); + + if (android.os.Build.VERSION.SDK_INT >= 19) { + touchExplorationStateChangeListener = new android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener({ + onTouchExplorationStateChanged(enabled) { + updateAccessibilityState(); + + if (Trace.isEnabled()) { + Trace.write(`TouchExplorationStateChangeListener state changed to: ${!!enabled}`, Trace.categories.Accessibility); + } + }, + }); + accessibilityManager.addTouchExplorationStateChangeListener(touchExplorationStateChangeListener); + } updateAccessibilityState();