Unable to view the same activity once user pushes app to background and bring back app to foreground?

Hi All,

I have used function : driver.sendKeyEvent(AndroidKeyCode.HOME); to move app to background …
Inorder to bring back to foreground i have used startActivity() - bundleid/Activity name as parameters

result :
Once user brings app to foreground , app is in different screen.

Please help to resolve this issue ?

  • When user switching form background/foreground , user should remains in the same screen.

use:

driver.sendKeyEvent(AndroidKeyCode.HOME);
try{driver.runAppInBackground(1);}catch(Exseption e){}

You might need to use a particular Intent flag. Perhaps try launching with Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY.