public void testClick(View v){
/**
* 方法1
*/
new Thread(){
public void run() {
Instrumentation in=new Instrumentation();
in.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
};
}.start();
/**
* 方法2
*/
new Thread(){
public void run() {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("input keyevent " + KeyEvent.KEYCODE_BACK);
} catch (IOException e) {
e.printStackTrace();
}
};
}.start();

}

更多相关文章

  1. android获取控件的几种方法
  2. Android 获取手机屏幕大小两种方法
  3. Android Timer 实现方法
  4. Android 显示/隐藏 软键盘 方法
  5. Android中的一些方法-----生生不息
  6. android 模拟器 PANIC: Could not open: AVD 解决方法
  7. Android里面WebView加载HTML里面点击按钮调我Android方法

随机推荐

  1. Android studio常见错误分析解决
  2. TabLayout 设置指示器宽度问题
  3. android studio 文件重命名快捷键
  4. Android 反射获得控件对象
  5. Android 升级Android Studio升级3.5提示
  6. Android 添加菜单
  7. [Android] ImageButton | Button | TextV
  8. Android weex的使用
  9. android取得当前程序File与Cache路径!
  10. Android改变标题栏背景和文字颜色