How do I close an active window?

Post your questions and help other users.

Moderator: Martin

Post Reply
icefox56
Posts: 53
Joined: 15 Aug 2017 02:56

How do I close an active window?

Post by icefox56 » 05 Oct 2019 15:06

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.
Asus Zenfone Max pro M1, Stock android, Oreo 8.1, Rooted

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How do I close an active window?

Post by Desmanto » 06 Oct 2019 17:12

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

icefox56
Posts: 53
Joined: 15 Aug 2017 02:56

Re: How do I close an active window?

Post by icefox56 » 06 Oct 2019 22:53

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();
Asus Zenfone Max pro M1, Stock android, Oreo 8.1, Rooted

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How do I close an active window?

Post by Desmanto » 09 Oct 2019 18:10

Just want to point out that you can swipe to remove it, and yes you have found it correctly.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

icefox56
Posts: 53
Joined: 15 Aug 2017 02:56

Re: How do I close an active window?

Post by icefox56 » 14 Oct 2019 09:27

The swipe to remove in the above script is hit or miss in my case.
Asus Zenfone Max pro M1, Stock android, Oreo 8.1, Rooted

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How do I close an active window?

Post by Desmanto » 03 Nov 2019 16:10

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply