Android AccessibilityService无障碍服务在8.0系统上的滑动方法

 

new GestureDescription.StrokeDescription(path, 200L, 800L,false)主要就是要加上fasle,这个只能在api>=26的基础上使用

 

private void topGestureClick() {

    GestureDescription.Builder builder = new GestureDescription.Builder();

    Path path = new Path();

    int y = 1200;

    int x = 360;

    path.moveTo(360, y);

 

    path.lineTo(x += 3, y -= 1000);

 

    GestureDescription gestureDescription = builder

            .addStroke(new GestureDescription.StrokeDescription(path, 200L, 800L,false))

            .build();

    dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() {

        @Override

        public void onCompleted(GestureDescription gestureDescription) {

            super.onCompleted(gestureDescription);

            Log.e(TAG, "123===onCompleted" );

            handler.postDelayed(new Runnable() {

                @Override

                public void run() {

                    leftGestureClick();

                }

            },3000);

        }

 

        @Override

        public void onCancelled(GestureDescription gestureDescription) {

            Log.e(TAG, "123===onCancelled" );

 

        }

    }, new Handler(Looper.getMainLooper()));

}

展开阅读全文

没有更多推荐了,返回首页