public void pressHomeButton() {
String simulatorAppName = "Simulator";
try {
String[] args = { "osascript", "-e", "tell application \"System Events\" \n tell application \""
+ simulatorAppName
+ "\" to activate \n tell application \"System Events\" to keystroke \"h\" using {command down, shift down} \n end tell" };
Process process = Runtime.getRuntime().exec(args);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String lsString;
while ((lsString = bufferedReader.readLine()) != null) {
System.out.println(lsString);
}
try {
Thread.sleep(200);
} catch (Exception e1) {
}
} catch (Exception e) {
}
}
Although its stale post, just thought to add a snippet here to help other folks on Mobile automation forum.