apk
1、获取权限
uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"
2、创建服务 用来展示悬浮窗
3、启动悬浮窗
uses-permission android:name="android.permission.FOREGROUND_SERVICE"
给Service设置无障碍模式
ScrollService需要继承AccessibilityService
点击 滑动 返回操作
@RequiresApi(Build.VERSION_CODES.N) protected void autoSlideView(float startX, float startY, float endX, float endY) { android.graphics.Path path = new android.graphics.Path(); path.moveTo(startX, startY); path.lineTo(endX, endY); GestureDescription gestureDescription = new GestureDescription.Builder() .addStroke(new GestureDescription.StrokeDescription(path, 0, 500)) .build(); dispatchGesture(gestureDescription, new GestureResultCallback() { @Override public void onCompleted(GestureDescription gestureDescription) { super.onCompleted(gestureDescription); }
@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
}
}, null);
}
@RequiresApi(Build.VERSION_CODES.N) protected void autoClickView(float startX, float startY) { android.graphics.Path path = new android.graphics.Path(); path.moveTo(startX, startY); GestureDescription gestureDescription = new GestureDescription.Builder() .addStroke(new GestureDescription.StrokeDescription(path, 0, 5)) .build(); dispatchGesture(gestureDescription, new GestureResultCallback() { @Override public void onCompleted(GestureDescription gestureDescription) { super.onCompleted(gestureDescription); }
@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
}
}, null);
}
protected void autoBackView() { performGlobalAction(GLOBAL_ACTION_BACK); }