Android examples for android.app:Instrumentation
send Key to Context
//package com.java2s; import android.app.Instrumentation; import android.content.Context; import android.os.AsyncTask; public class Main { public static final void sendKey(final Context context, Integer... keyCodes) { new AsyncTask<Integer, Void, Void>() { @Override//from w w w . j a v a 2s.c o m protected Void doInBackground(Integer... keyCodes1) { Instrumentation cInstrumentation = new Instrumentation(); for (Integer keyCode : keyCodes1) { cInstrumentation.sendKeyDownUpSync(keyCode); } return null; } protected void onPostExecute(Void result) { }; }.execute(keyCodes); } }