Page 1 of 1

How do I close an active window?

Posted: 05 Oct 2019 15:06
by icefox56
Suppose I used the action "Launch app" and launched a settings activity "com.android.settings.Settings$TetherSettingsActivity" which opens my hotspot settings. After performing a "Control UI" action there, I want to close that window completely (it should not even appear in recent apps list).

How can I do this?

My phone: Asus Zenfone Max Pro M1 (no root)
Android 8.1 Stock ROM

Edit: Nevermind. I added following to my control UI script, and it works well.

Code: Select all

click("OFF");
sleep(3000);
recents();
sleep(3000);
click("Dismiss Settings Hotspot & tet*");
home();
If there is a better method please do share.

Re: How do I close an active window?

Posted: 06 Oct 2019 17:12
by Desmanto
It should be the best solution already. You simply need to reduce the sleep to as low as the Control UI still work. 500 ms should be Ok, or you can try to lower.

Re: How do I close an active window?

Posted: 06 Oct 2019 22:53
by icefox56
I do want to reduce the sleep duration but I can't. It takes 3 seconds for the "X mark" to appear in recent screen. Do you know a better way to close that window?

Edit: I made it better & faster

Code: Select all

sleep(500);
click(962, 373);
recents();
sleep(500);
touchGesture(0, 217, newList(211, 1922, 1078, 1904));
home();

Re: How do I close an active window?

Posted: 09 Oct 2019 18:10
by Desmanto
Just want to point out that you can swipe to remove it, and yes you have found it correctly.

Re: How do I close an active window?

Posted: 14 Oct 2019 09:27
by icefox56
The swipe to remove in the above script is hit or miss in my case.

Re: How do I close an active window?

Posted: 03 Nov 2019 16:10
by Desmanto
You can try a longer sleep duration and see if it always work in longer sleep. If yes, then maybe the windows is not completely loaded up when you use shorter sleep duration. You can loop check for the element text using getTextInActiveWindow() for the app name you want to swipe out.