Step 1: Set up the accessibility agent

adSkipView.setAccessibilityDelegate(object : AccessibilityDelegate() { override fun performAccessibilityAction(host: View? , action: Int, args: Bundle?) : Boolean {/ / ignore AccessibilityService came the click event to achieve the purpose of prevent simulated click return the if (action = = AccessibilityNodeInfo. ACTION_CLICK | | the action  == AccessibilityNodeInfo.ACTION_LONG_CLICK) { true } else super.performAccessibilityAction(host, action, args) } })Copy the code

Step 2: Reject => unobstructed position simulation clicks

val accessibilityManager: AccessibilityManager = getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager adSkipView.setOnTouchListener({ v, event -> if (event.getAction() == MotionEvent.ACTION_DOWN) { if (null ! . = accessibilityManager && accessibilityManager isEnabled ()) {/ / can intercept barrier-free coordinates 】 【 click directly, Adskipview.setclickable (false)}} False})Copy the code

So that your opening ads don’t get skipped over by those who use a barrier-free analog click.