RunAppInBackground actually relaunches the app, but I want it to resume the same screen

@pr4bh4sh @Priyank_Shah RunAppInBackground actually relaunches the app, but I want it to resume the same screen.

How to do it?

Thanks,
Sanoj

If u want to maintain the context of app then

  1. Minimize it …

  2. Perform u r task …

  3. Maximize it …

     // Press Home Key
     	_driver.pressKeyCode(AndroidKeyCode.HOME);
     	
     	// KEYCODE_APP_SWITCH
     	_driver.pressKeyCode(0x000000bb);
     	_driver.findElementByAccessibilityId("app1Name");
     	// Tap our first app
     	List<WebElement> elem = _driver.findElements(By.className("android.widget.FrameLayout"));
     	
     	for (int i=0;i<elem.size()-1;i++){
     		System.out.println("elem.get(i).getAttribute(name) :: " + elem.get(i).getAttribute("name")) ;
     		if (elem.get(i).getAttribute("name").equals("WizIQ")){
     			System.out.println("Tapping :: " + elem.get(i).getAttribute("name")) ;
     			_driver.tap(1, elem.get(i), 100);
     			break;
     		}

actually its tricky way to do this. Just like human interaction. by pressing home key actually puts ur app into background. so in later stage to resume this app, you press on application tab and select app. You can do the same things using press key events.

@amitjaincoer191 thanks I will try and let you know the updates