Code example for AccessibilityEvent

Methods: getEventTimegetEventTypegetPackageName

         * {@code false} for non-selection events. 
        private boolean shouldDropEvent(AccessibilityEvent event) {
            // Only operate on selection events. Never drop granular movement 
            // events or other event types. 
            final int eventType = event.getEventType();
            if (eventType != AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED) {
                return false; 
            // Drop selected events until we've matched the number of changed 
            // events. This prevents TalkBack from speaking automatic cursor 
            // movement events that result from typing. 
            if (sAwaitingSelectionCount > 0) {
                final boolean hasDelayElapsed =
                        ((event.getEventTime() - sChangedTimestamp) >= SELECTION_DELAY);
                final boolean hasPackageChanged =
                        !TextUtils.equals(event.getPackageName(), sChangedPackage);
                // If the state is still consistent, update the count and drop 
                // the event. 
                if (!hasDelayElapsed && !hasPackageChanged) {
Experience pair programming with AI  Get Codota for Java