[ANDROID] How to switch to homescreen

I want to automate adding a widget on the home screen. But I am unable to perform any actions and keep getting a webdriverException being thrown. I am first launching an app and performing some actions, then I want to close the app and perform actions on the homescreen. How can I do that?