Press "Backspace" key via Instrumentation. - Android android.app

Android examples for android.app:Instrumentation

Description

Press "Backspace" key 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 www.  ja  v  a2 s  .co m*/
     * Press "Backspace".
     */
    public static void pressBackspace(Instrumentation instrumentation) {
        instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
                KeyEvent.KEYCODE_DEL));
        instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
                KeyEvent.KEYCODE_DEL));
        instrumentation.waitForIdleSync();
    }
}

Related Tutorials