要求:
代码实现按下Back 操作,返回到主页。
实现:
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("input keyevent " + KeyEvent.KEYCODE_BACK);
} catch (IOException e) {
e.printStackTrace();
}
Snackbar.make(view, "返回主页", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();