Android - want click on home button and relaunch application

I want to click on Home button present on Android device and again want to open the same application. Its native app.
I tried driver.runAppInBackground(8); however it relaunch the application. I don’t want to relaunch application it should start from the state where it was went to background.

I am using appium 1.4.8



1 - update to latest appium 1.5.X
2 - send client to background

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.HOME);

3 - reopen client later again

try {driver.runAppInBackground(1);}catch(Exception e){}

i already tried with driver.runAppinBackGround() but it does not open the app in state where it was went to background. it relaunch the application

did you try with sending client into background first and then runAppInBackground() ?

yes i tried it but its not working.

then you can first get to know what activity you suspending when press home screen with your application.

and after that driver.startActivity(your_activity) (example:

1 Like