原理
小米手机可以使用三个手指同时下滑截图
可以使用无障碍模拟该动作快速截图
代码如下
代码
public static void XiaoMiScreenCapture() {
int y1 = ScreenUtils.getScreenHeight() / 2 - 400;
int y2 = ScreenUtils.getScreenHeight() / 2 + 400;
int x1 = 200;
int x2 = ScreenUtils.getScreenWidth()/2;
int x3 = ScreenUtils.getScreenWidth()-200;
Path path1 = new Path();
path1.moveTo(x1, y1);
path1.lineTo(x1, y2);
Path path2 = new Path();
path2.moveTo(x2, y1);
path2.lineTo(x2, y2);
Path path3 = new Path();
path3.moveTo(x3, y1);
path3.lineTo(x3, y2);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder
.addStroke(new GestureDescription.StrokeDescription(path1, 0, 1000))
.addStroke(new GestureDescription.StrokeDescription(path2, 0, 1000))
.addStroke(new GestureDescription.StrokeDescription(path3, 0, 1000))
.build();
service.dispatchGesture(gestureDescription, null, null);
}
}
使用
调用XiaoMiScreenCapture
方法即可快速截图
网友评论