AutoService
向下滑动
private void playSwipe(int fromX, int fromY, int toX, int toY) { Path path = new Path(); path.moveTo(fromX, fromY); path.lineTo(toX, toY); GestureDescription.Builder builder = new GestureDescription.Builder(); builder.addStroke(new GestureDescription.StrokeDescription(path, 100L, 1000L)); GestureDescription gestureDescription = builder.build(); dispatchGesture(gestureDescription, new GestureResultCallback() { @Override public void onCompleted(GestureDescription gestureDescription) { super.onCompleted(gestureDescription); mHandler.postDelayed(mRunnable, mInterval); } @Override public void onCancelled(GestureDescription gestureDescription) { super.onCancelled(gestureDescription); } }, null); }
点击屏幕
private void playTap(int x, int y) { Path path = new Path(); path.moveTo(x, y); path.lineTo(x, y); GestureDescription.Builder builder = new GestureDescription.Builder(); builder.addStroke(new GestureDescription.StrokeDescription(path, 10L, 10L)); GestureDescription gestureDescription = builder.build(); dispatchGesture(gestureDescription, new GestureResultCallback() { @Override public void onCompleted(GestureDescription gestureDescription) { super.onCompleted(gestureDescription); mHandler.postDelayed(mRunnable, mInterval); } @Override public void onCancelled(GestureDescription gestureDescription) { super.onCancelled(gestureDescription); } }, null); }