Android examples for User Interface:Key Event
Press "Back" on key board
// Copyright 2012 The Chromium Authors. All rights reserved. //package com.java2s; import android.app.Instrumentation; import android.view.KeyEvent; public class Main { /**/* w w w. j a v a 2 s . c o m*/ * Press "Back". */ public static void pressBack(Instrumentation instrumentation) { instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK)); instrumentation.waitForIdleSync(); } }