Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll up and scroll down using AccessibilityNodeInfo in Accessibility Service

I want to perform scroll using Accessibility service and i am doing this

public boolean scrollView(AccessibilityNodeInfo nodeInfo) {

if (nodeInfo == null) return false;

if (nodeInfo.isScrollable()) {
    return nodeInfo.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}

for (int i = 0; i < nodeInfo.getChildCount(); i++) {
    if (scrollView(nodeInfo.getChild(i)) {
        return true;
    }
}

return false; }

But problem is when there are four option to perform up,down left and right it performs left and right but i want to perform up and down there also. like in facebook app it scroll on top section where notifications and news feed are.But not on page. is there any way to scroll where is focus of user.

like image 252
Ali Asjad Avatar asked Jun 26 '26 20:06

Ali Asjad


1 Answers

You're probably scrolling the wrong container. There are likely multiple views in your heirarchy that are "scrollable". Try finding different scrollable views within your heirarchy.

Also, in Android M they added APIs to do things like specifically scroll different directions. So, if you are in fact on the correct View, you can scroll in different directions using these actions instead:

ACTION_SCROLL_FORWARD
ACTION_SCROLL_LEFT
ACTION_SCROLL_RIGHT

etc.

https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.AccessibilityAction.html

like image 77
ChrisCM Avatar answered Jun 29 '26 11:06

ChrisCM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!