Mobile reset will reset the app's state.
Ruby + appium_lib gem
mobile :reset
Ruby without the gem
@driver.execute_script 'mobile: reset'
KeyEvent enables sending a keycode to Android.
Press the system menu button in Java.
HashMap<String, Integer> keycode = new HashMap<String, Integer>();
keycode.put("keycode", 82);
((JavascriptExecutor)driver).executeScript("mobile: keyevent", keycode);
Ruby + appium_lib gem
mobile :keyevent, keycode: 82
Ruby without the gem
@driver.execute_script 'mobile: keyevent', :keycode => 82
Java
JSONArray json = new JSONArray();
json.put("scroll");
json.put(new JSONArray().put(new JSONArray().put(3).put("Gallery")));
json.put(new JSONArray().put(new JSONArray().put(7).put("Gallery")));
// json is now: ["scroll",[[3,"Gallery"]],[[7,"Gallery"]]]
((JavascriptExecutor) driver).executeScript("mobile: find", json);
Ruby + appium_lib gem
scroll_to 'Gallery'