Code example for Instrumentation

Methods: sendPointerSync, sleep

0
        } 
    } 
 
    private static void wait_msec(int i) {
        try { 
            Thread.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } 
    } 
 
    /** 
     * 単純なタップを再現するタスク 
     **/ 
    public static class SimpleTapEventSender 
            extends AsyncTask<Integer, Integer, Integer> {
        /** 
         * @param Integer : x座標、y座標 
         */ 
        @Override 
        protected Integer doInBackground(Integer... params) {
            Log.i(TAG, "pushsync aaa");
            if (params.length < 2)
                return null; 
 
            Instrumentation ist = new Instrumentation();
            MotionEvent event;
 
            event = MotionEvent.obtain(SystemClock.uptimeMillis(),
                    SystemClock.uptimeMillis(),
                    MotionEvent.ACTION_DOWN,
                    params[0],
                    params[1],
                    0); 
            ist.sendPointerSync(event);
            wait_msec(400); 
            event = MotionEvent.obtain(SystemClock.uptimeMillis(),
                    SystemClock.uptimeMillis(),
                    MotionEvent.ACTION_UP,
                    params[0],
                    params[1],
                    0); 
            ist.sendPointerSync(event);
            return null; 
        } 
    } 
 
    /**