This is an example of Automate flow. To learn more about Automate for Android phones, click here.
This is a very simple Automate flow with only 4 blocks (including the Flow beginning block).
Most if not all Android launchers support multiple screens for you to organize your apps and widgets into different screen as needed. One of the screens is your Home screen, which normally is where you put your mostly accessed apps and widgets.
When you are at the launcher screen without any opened foreground app, you can always go back to the Home screen by pressing your phone's Home soft key or Home button.
If most of the time, when you unlock your phone and start using it, you want to be at the Home screen regardless of which launcher screen you were at when your phone went to sleep and locked itself, this is exactly what this Automate flow will do.
This flow will wait until you unlock the phone, and check if you are at the launcher screen (meaning, no app is opened at the foreground). If yes, it will emulate pressing the Home button so that you will go to the Home screen automatically.
If you were running an app at the foreground (such as Whatsapp, browser, email, Facebook, etc.) when the screen was last locked, the flow will do nothing and you will return to the app screen after unlock.
In order for this flow to work properly, you need to set the correct launcher app of your phone in the "Is foreground app" block, because different Android phone vendor might provide their own launcher app to the phone. In addition, Android system also allows you to install and use 3rd party launcher app such as Nova launcher, Apex launcher, TSF launcher, etc.
You can tap on the "Pick activity..." button as shown above to select the launcher app you use in your phone.
The setting in the above screen is for Samsung TouchWiz launcher. For HTC phones, set the Package to "com.htc.launcher" and leave the Activity Class as empty field.
What if you never set any screen lock to your phone? In that case, you just need to change the "When device unlocked" block to "When screen is on" block.