'How to use an android accessibility service to detect which view the user touched?

There's something that android TalkBack does that I want to do too. Specifically it's to identify the view that the user touched. I made this so far:

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) {

        //This only shows the package of the activity that the view is in, I want to identify the view itself
        Toast.makeText(this, "" + event.getSource().getPackageName(), Toast.LENGTH_LONG).show();
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source