I have tried the following code for the above mentioned problem,
driver.pressKey(new KeyEvent().withKey(AndroidKey.APP_SWITCH));
//Code for swipe left
((AndroidDriver) driver).startActivity(new Activity(ANDROID_PACKAGE, ANDROID_STARTACTIVITY));
//user you application package name and activity for start application
When I switch between applications my previous application gets restart. Could anyone please help me to stop this restart.
Key presses on appium are done by
driver.press_keycode(code)
All required codes can be found here
So in your case, The final code would be like,
driver.press_keycode(187)
- KEYCODE_APP_SWITCH