runAppBackground() method does not take you to the left activity.It always takes to the main activity


1- I have opened the main activity.
2- then done few click/action and moved to some other page.
3- Now called the runAppInBackground(5);
4- Now It is again taking me to main activity instead of the left activity.
5- Please suggest me the way to achieve this.

That is always there, because appium does not store last activity in context. so when you launch activity using driver.launchActivity() it always start from scratch. So you need to handle programatically.
Clicking on application tab -> select running app from applications tab

Thanks for your immediate reply. I dont launch it again. I just ran the runAppBackgroud(). That will take go background for 5 sec and came back with launch activity which I did not expect. Can you please tell the way open the minimize application from the minimized list of app.

Yes, that i want to tell. When u launch activity using driver.launchActivity(); it will not the same activity which u had been before. So basically you need to emulate this things using script.

driver.findElement(By.AccesibilityId(“App Name”)).click();

There is no such class like AndroidKeyEvents. I dont find in my latest appium client jar 3.2

I have used KEYCODE_APP_SWITCH where it takes me to application switcher dialog. but how to select my app and other app from the dialog switcher using AndroidKeycode