Java tutorial
//package com.java2s; import android.app.Instrumentation; public class Main { public static void sendKeyIntent(final int keycode) { new Thread(new Runnable() { @Override public void run() { new Instrumentation().sendKeyDownUpSync(keycode); } }).start(); } }