Code example for Instrumentation

Methods: sendPointerSync

0
        // event time MUST be retrieved only by this way! 
        long eventTime = SystemClock.uptimeMillis();
        if(!fingerDown)
        { 
            MotionEvent downEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, realX, realY, 0);
            inst.sendPointerSync(downEvent);
        } 
        MotionEvent upEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, realX, realY, 0);
        inst.sendPointerSync(upEvent);
    } 
     
    public void touchStart(int x, int y)
    { 
        int realX = getRealCoord(x);
        int realY = getRealCoord(y);
        long downTime = SystemClock.uptimeMillis();
        // event time MUST be retrieved only by this way! 
        long eventTime = SystemClock.uptimeMillis();
        MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, realX, realY, 0);
        inst.sendPointerSync(event);
Experience pair programming with AI  Get Codota for Java