Android - want click on home button and relaunch application

hi,
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

Thanks
Nilesh

hi,

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.

ok.
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: https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidActivityTest.java)

1 Like