Android??????????????????????
???????????? ???????[ 2013/8/26 13:54:31 ] ????????
????????????????????????????????ACTION_DOWN???????????伴?????????????
/**
* ????????????????????????????λ??
* @param viewFrom ???View
* @param viewTo ???View
* @throws Exception
*/
public void clickLongAndDrag(View viewFrom??View viewTo) throws Exception {
//??????View???????????x??y????
final int[] location = new int[2];
final int[] location2 = new int[2];
viewFrom.getLocationOnScreen(location);
viewTo.getLocationOnScreen(location2);
float xStart=location[0];
float yStart=location[1];
float xStop=location2[0];
float yStop=location2[1];
Log.i(TAG?? "xStart:"+String.valueOf(xStart));
Log.i(TAG?? "yStart:"+String.valueOf(yStart));
Log.i(TAG?? "xStop:"+String.valueOf(xStop));
Log.i(TAG?? "yStop:"+String.valueOf(yStop));
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
try{
MotionEvent event = MotionEvent.obtain(downTime?? eventTime?? MotionEvent.ACTION_DOWN?? xStart+10f?? yStart+10f?? 0);
inst.sendPointerSync(event);
//event = MotionEvent.obtain(downTime?? eventTime?? MotionEvent.ACTION_MOVE?? xStart+10f+1.0f?? yStart+10f+1.0f?? 0);
//inst.sendPointerSync(event);
//Thread.sleep(1000);
//???????????????
eventTime = SystemClock.uptimeMillis() + 1000;
//xStop????10??????????View????????????????????????????
event = MotionEvent.obtain(downTime?? eventTime?? MotionEvent.ACTION_MOVE?? xStop+10f?? yStop+50f?? 0);
inst.sendPointerSync(event);
eventTime = SystemClock.uptimeMillis() + 1000;
//????СС???????Σ???????????????????????????????????View??????????????λ??
event = MotionEvent.obtain(downTime?? eventTime?? MotionEvent.ACTION_MOVE?? xStop+10f?? yStop+10f?? 0);
inst.sendPointerSync(event);
eventTime = SystemClock.uptimeMillis() + 1000;
event = MotionEvent.obtain(downTime?? eventTime?? MotionEvent.ACTION_UP?? xStop+10f?? yStop+10f?? 0);
inst.sendPointerSync(event);
}catch (Exception ignored) {
// Handle exceptions if necessary
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11