android模拟手指滑动,Android Accessibility 模拟界面滑动
1 Accessibility配置請查看https://blog.csdn.net/qq_27885521/article/details/102910188
2 繪制path
Path mPath = new Path();//線性的path代表手勢路徑,點代表按下,封閉的沒用
//x y坐標 下面例子是往下滑動界面
mPath.moveTo(100,200);//代表從哪個點開始滑動
mPath.lineTo(100,100);//滑動到哪個點
3 模擬繪制手勢
MainService.mainService.dispatchGesture(new GestureDescription.Builder().addStroke(new GestureDescription.StrokeDescription
(mPath, 20, 500)).build(), new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
Toast.makeText(TransparentActivity.this, "模擬手勢成功", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
Toast.makeText(TransparentActivity.this, "模擬手勢失敗",Toast.LENGTH_SHORT).show();
}
}, null);
總結
以上是生活随笔為你收集整理的android模拟手指滑动,Android Accessibility 模拟界面滑动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 打新稳赚不赔吗 在A股基本上是这样
- 下一篇: 长春8中2021年高考 成绩查询,长春八