Press "Tab" via Instrumentation. - Android android.app

Android examples for android.app:Instrumentation

Description

Press "Tab" via Instrumentation.

Demo Code

// Copyright 2012 The Chromium Authors. All rights reserved.
//package com.java2s;
import android.app.Instrumentation;
import android.view.KeyEvent;

public class Main {
    /**/*from   w ww.j  av a2  s .  c  o  m*/
     * Press "Tab".
     */
    public static void pressTab(Instrumentation instrumentation) {
        instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
                KeyEvent.KEYCODE_TAB));
        instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
                KeyEvent.KEYCODE_TAB));
        instrumentation.waitForIdleSync();
    }
}

Related Tutorials