Code example for Instrumentation

Methods: sendPointerSyncwaitForIdleSync

    private static void sendAction(Instrumentation instrumentation, int action, long downTime,
            float x, float y) {
        long eventTime = SystemClock.uptimeMillis();
        MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, 0);
     * Sends (synchronously) a single click to an absolute screen coordinates. 
     * @param instrumentation Instrumentation object used by the test. 
     * @param x Screen absolute x location. 
     * @param y Screen absolute y location. 
    public static void singleClick(Instrumentation instrumentation, float x, float y) {
        long downTime = SystemClock.uptimeMillis();
        sendAction(instrumentation, MotionEvent.ACTION_DOWN, downTime, x, y);
        sendAction(instrumentation, MotionEvent.ACTION_UP, downTime, x, y);