title: How to listen to clicks from views in using AccessibilityNodeInfoCompat in android?
body: <p>When the user clicks AccessibilityNodeInfoCompat, how can I listen to the click to this views in android ? I tried sendMessageButton.actions==AccessibilityEvents.ACTION_CLICK, but no luck for me. By the way, I am inside whatsapp
  Here is my AccessibilityService class</p>
  <pre><code> 
  class MyService : AccessibilityService() {
  
      private var current = 0;
      private val TAG = &quot;MyService&quot;
  
      override fun onServiceConnected() {
          Log.e(TAG, &quot;onServiceConnected: Service is connected...&quot;)
      }
  
      override fun onAccessibilityEvent(event: AccessibilityEvent) {
          Log.e(TAG, &quot;onAccessibilityEvent:  $event&quot;)
          if (event.packageName.equals(&quot;com.whatsapp&quot;)) {
              Log.e(TAG, &quot;onAccessibilityEvent: Event  : $event&quot;)
          }
          listenToClickEveryTime(event);
      }
  
      private fun listenToClickEveryTime(event: AccessibilityEvent) {
          try {
              if (rootInActiveWindow == null)
                  return
  
              val rootInActiveWindow = AccessibilityNodeInfoCompat.wrap(rootInActiveWindow);
  
              Log.e(TAG, &quot;performClickEveryTime: InitialViews $rootInActiveWindow&quot;)
  
              val sendMessageNodeInfoList =
                  rootInActiveWindow.findAccessibilityNodeInfosByViewId(&quot;com.whatsapp:id/send&quot;);
  
              if (sendMessageNodeInfoList == null || sendMessageNodeInfoList.isEmpty())
                  return
  
              for (k in sendMessageNodeInfoList) {
                  Log.e(TAG, &quot;onAccessibilityEvent: Views : ${k}&quot;)
              }
  
              val sendMessageButton = sendMessageNodeInfoList.get(0);
  
              if (!sendMessageButton.isVisibleToUser)
                  return
              
              //sendMessageButton    I need to listen to clicks to this view 
              
  //            sendMessageButton.performAction(AccessibilityNodeInfo.ACTION_CLICK); This clicks the imageButton automatically.
  
          } catch (ex: Exception) {
              Log.e(TAG, &quot;onAccessibilityEvent: &quot;, ex)
          }
  
      }
  
  </code></pre>