android-代码里模拟发送按键

//KeyEvent.KEYCODE_MENU
	//KeyEvent.KEYCODE_BACK
	 public static void sendKeyEvent(final int KeyCode) {
	       new Thread() {     //不可在主线程中调用
	            public void run() {
	                try {
	                    Instrumentation inst = new Instrumentation();
	                    inst.sendKeyDownUpSync(KeyCode);
	               } catch (Exception e) {
	                    e.printStackTrace();
	                }
	             }
	   
	        }.start();
	 }

你可能感兴趣的:(android,UI)