how to ensure you get to the home or main screen of an app

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

how to ensure you get to the home or main screen of an app

Post by tsolignani » 28 Aug 2019 06:42

I have several flows with control UI (love it!) where the flow needs the app to be into its main or home page to work. If I try to kill the app and realunch it many times it doesn't work (it doesn't quit, even when in background).

Is there any other way to make sure an app is in its main page when activated, as when launched for the first time?

Thank you.

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

Re: how to ensure you get to the home or main screen of an app

Post by Desmanto » 29 Aug 2019 19:15

How about adding back() several times to ensure it always back-ed until the main page of the app. This varies depends on the app. You can add additional check for certain element in the app before executing the main script. Example if the app is now in level 2, you can use back(); sleep(100); back(), to back twice to the main screen. Check for any element Id that might be there using existsElementById(), choose the element that only appear at the sub menu level 2. Do the same also for other sub menu.

Or you can make universal back() if there is certain element that only exists in main screen. So the script will loop back() if this element is not exists. Example for Gmail, the search box is always in the main screen.

Code: Select all

loop = 0;
if(!existsElementById("com.google.android.gm:id/open_search") AND loop <= 5)
{
  back();
  loop = loop + 1;
  sleep(100);
}
This ensure it will press back() until it back to main screen. I add check for loop is less than equal to 5. This protect so the back is only pressed maximum 5 times, in case you mis-run the script not inside Gmail.
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.

User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

Re: how to ensure you get to the home or main screen of an app

Post by tsolignani » 30 Aug 2019 07:12

Just great! Thank you so much. I am not only fixing my flows, but learning many things.

Have a nice day.

User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

Re: how to ensure you get to the home or main screen of an app

Post by tsolignani » 30 Aug 2019 15:23

It does work! Wonderful. Thanks again.

Post Reply